File tree 3 files changed +56
-8
lines changed
features/03_testing_frameworks/cucumber/steps/command
3 files changed +56
-8
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,38 @@ Feature: All output of commands which were executed
327
327
When I run `cucumber`
328
328
Then the features should all pass
329
329
330
+ Scenario : Match passing exit status but fail to match exact output
331
+ Given an executable named "bin/aruba-test-cli" with:
332
+ """bash
333
+ #!/usr/bin/env bash
334
+
335
+ echo -ne "hello\nworld"
336
+ exit 0
337
+ """
338
+ And a file named "features/output.feature" with:
339
+ """cucumber
340
+ Feature: Run command
341
+ Scenario: Run command
342
+ When I run `aruba-test-cli`
343
+ Then it should pass with exactly:
344
+ \"\"\"
345
+ hello
346
+ worl
347
+ \"\"\"
348
+ """
349
+ When I run `cucumber`
350
+ Then the features should not pass with:
351
+ """
352
+ expected "hello
353
+ world" to output string is eq: "hello
354
+ worl"
355
+ Diff:
356
+ @@ -1,3 +1,3 @@
357
+ hello
358
+ -worl
359
+ +world
360
+ """
361
+
330
362
Scenario : Match failing exit status and partial output
331
363
Given an executable named "bin/aruba-test-cli" with:
332
364
"""bash
Original file line number Diff line number Diff line change @@ -66,3 +66,23 @@ Feature: STDERR of commands which were executed
66
66
"""
67
67
When I run `cucumber`
68
68
Then the features should all pass
69
+
70
+ Scenario : Failure message when checking that stderr from all processes is empty
71
+ Given a file named "features/output.feature" with:
72
+ """
73
+ Feature: Run command
74
+ Scenario: Run command
75
+ When I run `bash -c 'printf "hello\nworld!\n" >&2'`
76
+ And I run `printf "hola"`
77
+ And the stderr should not contain anything
78
+ """
79
+ When I run `cucumber`
80
+ Then the features should not pass with:
81
+ """
82
+ expected "hello
83
+ world!" to output string is eq: ""
84
+ Diff:
85
+ @@ -1,2 +1,4 @@
86
+ +hello
87
+ +world!
88
+ """
Original file line number Diff line number Diff line change 423
423
expect ( last_command_stopped ) . not_to be_successfully_executed
424
424
end
425
425
426
- expect ( last_command_stopped ) . to have_output an_output_string_being_eq ( expected )
426
+ expect ( last_command_stopped . output ) . to output_string_eq ( expected )
427
427
end
428
428
429
429
Then ( /^it should not (pass|fail) (?:with regexp?|matching):$/ ) do |pass_fail , expected |
450
450
expect ( last_command_stopped ) . to have_output an_output_string_matching ( expected )
451
451
end
452
452
453
- Then ( /^(?:the )?(output|stderr|stdout) should not contain anything$/ ) do |channel |
454
- matcher = case channel
455
- when 'output' ; then :have_output
456
- when 'stderr' ; then :have_output_on_stderr
457
- when 'stdout' ; then :have_output_on_stdout
458
- end
453
+ Then '(the ){channel} should not contain anything' do |channel |
454
+ combined_output = send ( :"all_#{ channel } " )
459
455
460
- expect ( all_commands ) . to include send ( matcher , be_nil . or ( be_empty ) )
456
+ expect ( combined_output ) . to output_string_eq ''
461
457
end
462
458
463
459
Then ( /^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/ ) \
You can’t perform that action at this time.
0 commit comments