Skip to content

Commit

Permalink
Fix cucumber step '<channel> should not contain anything'
Browse files Browse the repository at this point in the history
This fixes two things:

- It requires all commands to have no output on the channel, not just
  one.
- It improves the failure message so that it shows the actual output.
  • Loading branch information
mvz committed Nov 20, 2024
1 parent 6b05a86 commit 403e18b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,23 @@ Feature: STDERR of commands which were executed
"""
When I run `cucumber`
Then the features should all pass

Scenario: Failure message when checking that stderr from all processes is empty
Given a file named "features/output.feature" with:
"""
Feature: Run command
Scenario: Run command
When I run `bash -c 'printf "hello\nworld!\n" >&2'`
And I run `printf "hola"`
And the stderr should not contain anything
"""
When I run `cucumber`
Then the features should not pass with:
"""
expected "hello
world!" to output string is eq: ""
Diff:
@@ -1,2 +1,4 @@
+hello
+world!
"""
10 changes: 3 additions & 7 deletions lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,10 @@
expect(last_command_stopped).to have_output an_output_string_matching(expected)
end

Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
matcher = case channel
when 'output'; then :have_output
when 'stderr'; then :have_output_on_stderr
when 'stdout'; then :have_output_on_stdout
end
Then '(the ){channel} should not contain anything' do |channel|
combined_output = send(:"all_#{channel}")

expect(all_commands).to include send(matcher, be_nil.or(be_empty))
expect(combined_output).to output_string_eq ''
end

Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) \
Expand Down

0 comments on commit 403e18b

Please sign in to comment.