зеркало из https://github.com/mislav/hub.git
Fix assertions that fail on whitespace mismatch
This commit is contained in:
Родитель
96ec4a56b5
Коммит
f0e182a0e2
|
@ -231,7 +231,7 @@ Feature: hub api
|
|||
"""
|
||||
Then the output should contain exactly:
|
||||
"""
|
||||
.query query {\n repository\n}\n
|
||||
.query query {\\n repository\\n}\\n\n
|
||||
"""
|
||||
|
||||
Scenario: POST body from file
|
||||
|
@ -340,7 +340,7 @@ Feature: hub api
|
|||
"""
|
||||
Then the output should contain exactly:
|
||||
"""
|
||||
.query repository(owner: "octocat", name: "Hello-World", nameWithOwner: "octocat/Hello-World")\n
|
||||
.query repository(owner: "octocat", name: "Hello-World", nameWithOwner: "octocat/Hello-World")\\n\n
|
||||
"""
|
||||
|
||||
Scenario: Cache response
|
||||
|
@ -508,7 +508,7 @@ Feature: hub api
|
|||
"""
|
||||
{}
|
||||
Your access token may have insufficient scopes. Visit http://github.com/settings/tokens
|
||||
to edit the 'hub' token and enable one of the following scopes: admin, repo
|
||||
to edit the 'hub' token and enable one of the following scopes: admin, repo\n
|
||||
"""
|
||||
|
||||
Scenario: Print the SSO challenge to stderr
|
||||
|
@ -526,5 +526,5 @@ Feature: hub api
|
|||
"""
|
||||
|
||||
You must authorize your token to access this organization:
|
||||
http://example.com?auth=HASH
|
||||
http://example.com?auth=HASH\n
|
||||
"""
|
||||
|
|
|
@ -18,7 +18,6 @@ Feature: hub apply
|
|||
}
|
||||
"""
|
||||
When I successfully run `hub apply -3 https://github.com/mislav/dotfiles/pull/387`
|
||||
Then the output should not contain anything
|
||||
Then a file named "README.md" should exist
|
||||
|
||||
Scenario: Apply commits when TMPDIR is empty
|
||||
|
|
|
@ -536,5 +536,5 @@ Feature: OAuth authentication
|
|||
"""
|
||||
Error fetching releases: Forbidden (HTTP 403)
|
||||
You must authorize your token to access this organization:
|
||||
http://example.com?auth=HASH
|
||||
http://example.com?auth=HASH\n
|
||||
"""
|
||||
|
|
|
@ -21,14 +21,14 @@ Feature: hub compare
|
|||
Scenario: No args, no upstream
|
||||
When I run `hub compare`
|
||||
Then the exit status should be 1
|
||||
And the stderr should contain exactly "the current branch 'master' doesn't seem pushed to a remote"
|
||||
And the stderr should contain exactly "the current branch 'master' doesn't seem pushed to a remote\n"
|
||||
|
||||
Scenario: Can't compare default branch to self
|
||||
Given the default branch for "origin" is "develop"
|
||||
And I am on the "develop" branch with upstream "origin/develop"
|
||||
When I run `hub compare`
|
||||
Then the exit status should be 1
|
||||
And the stderr should contain exactly "the branch to compare 'develop' is the default branch"
|
||||
And the stderr should contain exactly "the branch to compare 'develop' is the default branch\n"
|
||||
|
||||
Scenario: No args, has upstream branch
|
||||
Given I am on the "feature" branch with upstream "origin/experimental"
|
||||
|
|
|
@ -19,7 +19,7 @@ Feature: hub gist
|
|||
When I successfully run `hub gist show myhash`
|
||||
Then the output should contain exactly:
|
||||
"""
|
||||
my content is here
|
||||
my content is here\n
|
||||
"""
|
||||
|
||||
Scenario: Fetch a gist with many files
|
||||
|
@ -70,7 +70,7 @@ Feature: hub gist
|
|||
When I successfully run `hub gist show myhash hub_gist1.txt`
|
||||
Then the output should contain exactly:
|
||||
"""
|
||||
my content is here
|
||||
my content is here\n
|
||||
"""
|
||||
|
||||
Scenario: Create a gist from file
|
||||
|
@ -88,7 +88,7 @@ Feature: hub gist
|
|||
When I successfully run `hub gist create testfile.txt`
|
||||
Then the output should contain exactly:
|
||||
"""
|
||||
http://gists.github.com/somehash
|
||||
http://gists.github.com/somehash\n
|
||||
"""
|
||||
|
||||
Scenario: Open the new gist in a browser
|
||||
|
@ -130,7 +130,7 @@ Feature: hub gist
|
|||
When I successfully run `hub gist create testfile.txt testfile2.txt`
|
||||
Then the output should contain exactly:
|
||||
"""
|
||||
http://gists.github.com/somehash
|
||||
http://gists.github.com/somehash\n
|
||||
"""
|
||||
|
||||
Scenario: Create a gist from stdin
|
||||
|
@ -149,7 +149,7 @@ Feature: hub gist
|
|||
"""
|
||||
Then the output should contain exactly:
|
||||
"""
|
||||
http://gists.github.com/somehash
|
||||
http://gists.github.com/somehash\n
|
||||
"""
|
||||
|
||||
Scenario: Insufficient OAuth scopes
|
||||
|
@ -172,7 +172,7 @@ Feature: hub gist
|
|||
"""
|
||||
Error creating gist: Not Found (HTTP 404)
|
||||
Your access token may have insufficient scopes. Visit http://github.com/settings/tokens
|
||||
to edit the 'hub' token and enable one of the following scopes: gist
|
||||
to edit the 'hub' token and enable one of the following scopes: gist\n
|
||||
"""
|
||||
|
||||
Scenario: Infer correct OAuth scopes for gist
|
||||
|
@ -194,7 +194,7 @@ Feature: hub gist
|
|||
"""
|
||||
Error creating gist: Not Found (HTTP 404)
|
||||
Your access token may have insufficient scopes. Visit http://github.com/settings/tokens
|
||||
to edit the 'hub' token and enable one of the following scopes: gist
|
||||
to edit the 'hub' token and enable one of the following scopes: gist\n
|
||||
"""
|
||||
|
||||
Scenario: Create error
|
||||
|
|
|
@ -112,6 +112,7 @@ Feature: hub pr list
|
|||
#102 luke, jyn\n
|
||||
"""
|
||||
|
||||
@keep-ansi-escape-sequences
|
||||
Scenario: List draft status
|
||||
Given the GitHub API server:
|
||||
"""
|
||||
|
|
|
@ -69,7 +69,7 @@ Feature: hub pr show
|
|||
Then "open https://github.com/ashemesh/hub/pull/102" should not be run
|
||||
And the output should contain exactly:
|
||||
"""
|
||||
#102 rey, github/troopers, github/cantina-band\n
|
||||
#102 rey, github/troopers, github/cantina-band\n\n
|
||||
"""
|
||||
|
||||
Scenario: Current branch in fork
|
||||
|
@ -208,7 +208,7 @@ Feature: hub pr show
|
|||
Then "open https://github.com/ashemesh/hub/pull/102" should not be run
|
||||
And the output should contain exactly:
|
||||
"""
|
||||
#102 rey, github/troopers, github/cantina-band\n
|
||||
#102 rey, github/troopers, github/cantina-band\n\n
|
||||
"""
|
||||
|
||||
Scenario: Show pull request by invalid number
|
||||
|
|
|
@ -1241,7 +1241,7 @@ Feature: hub pull-request
|
|||
And stderr should contain exactly:
|
||||
"""
|
||||
Error creating pull request: Post https://api.github.com/repositories/12345/pulls: refusing to follow HTTP 301 redirect for a POST request
|
||||
Have your site admin use HTTP 308 for this kind of redirect
|
||||
Have your site admin use HTTP 308 for this kind of redirect\n
|
||||
"""
|
||||
|
||||
Scenario: Default message with --push
|
||||
|
|
|
@ -359,7 +359,7 @@ MARKDOWN
|
|||
### Hello to my release
|
||||
|
||||
Here is what's broken:
|
||||
- everything\n
|
||||
- everything\n\n
|
||||
"""
|
||||
|
||||
Scenario: Show release no tag
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
# Avoids over-zealous sanitize_text
|
||||
# https://github.com/cucumber/aruba/blob/v1.0.4/lib/aruba/matchers/string/output_string_eq.rb
|
||||
|
||||
sanitize_text = ->(expected) {
|
||||
expected.to_s.
|
||||
# convert "\n" in expectations to literal newline, unless it is preceded by another backslash
|
||||
gsub(/(?<!\\)\\n/, "\n").
|
||||
# convert "\e" in expectations to a literal ESC, unless it is preceded by another backslash
|
||||
gsub(/(?<!\\)\\e/, "\e").
|
||||
gsub('\\\\', '\\')
|
||||
}
|
||||
|
||||
RSpec::Matchers.define :output_string_eq do |expected|
|
||||
match do |actual|
|
||||
@expected = sanitize_text.(expected)
|
||||
@actual = actual.to_s
|
||||
@actual = extract_text(@actual) if aruba.config.remove_ansi_escape_sequences
|
||||
|
||||
@expected == @actual
|
||||
end
|
||||
|
||||
diffable
|
||||
|
||||
description { "output string is eq: #{description_of(self.expected)}" }
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :have_output do |expected|
|
||||
match do |actual|
|
||||
@old_actual = actual
|
||||
|
||||
unless @old_actual.respond_to? :output
|
||||
raise "Expected #{@old_actual} to respond to #output"
|
||||
end
|
||||
|
||||
@old_actual.stop
|
||||
|
||||
@actual = actual.output
|
||||
@actual = extract_text(@actual) if aruba.config.remove_ansi_escape_sequences
|
||||
|
||||
expected === @actual
|
||||
end
|
||||
|
||||
diffable
|
||||
|
||||
description { "have output: #{description_of(expected)}" }
|
||||
|
||||
failure_message do |_actual|
|
||||
"expected `#{@old_actual.commandline}` to #{description_of(expected)}\n" \
|
||||
"but was: #{description_of(@actual)}"
|
||||
end
|
||||
end
|
||||
|
||||
RSpec::Matchers.alias_matcher :an_output_string_being_eq, :output_string_eq
|
Загрузка…
Ссылка в новой задаче