Skip to content

Commit

Permalink
Fix cucumber step 'it should pass|fail with exactly:'
Browse files Browse the repository at this point in the history
This fixes the failure message of the output comparison so that it shows
the correct diff.
  • Loading branch information
mvz committed Nov 20, 2024
1 parent 403e18b commit 411fdc9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,38 @@ Feature: All output of commands which were executed
When I run `cucumber`
Then the features should all pass

Scenario: Match passing exit status but fail to match exact output
Given an executable named "bin/aruba-test-cli" with:
"""bash
#!/usr/bin/env bash
echo -ne "hello\nworld"
exit 0
"""
And a file named "features/output.feature" with:
"""cucumber
Feature: Run command
Scenario: Run command
When I run `aruba-test-cli`
Then it should pass with exactly:
\"\"\"
hello
worl
\"\"\"
"""
When I run `cucumber`
Then the features should not pass with:
"""
expected "hello
world" to output string is eq: "hello
worl"
Diff:
@@ -1,3 +1,3 @@
hello
-worl
+world
"""

Scenario: Match failing exit status and partial output
Given an executable named "bin/aruba-test-cli" with:
"""bash
Expand Down
2 changes: 1 addition & 1 deletion lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@
expect(last_command_stopped).not_to be_successfully_executed
end

expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
expect(last_command_stopped.output).to output_string_eq(expected)
end

Then(/^it should not (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
Expand Down

0 comments on commit 411fdc9

Please sign in to comment.