1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
Feature: AfterStep Hooks
AfterStep hooks can be used to further inspect the Step object of the step
that has just run, or to simply check the step's result.
Background:
Given the standard step definitions
And a file named "features/sample.feature" with:
"""
Feature: Sample
Scenario: Success
Given this step passes
"""
Scenario: Access Test Step object in AfterStep Block
Given a file named "features/support/env.rb" with:
"""
AfterStep do |result, test_step|
expect(test_step).to be_a(Cucumber::Core::Test::Step)
end
"""
When I run `cucumber features`
Then it should pass with:
"""
Feature: Sample
Scenario: Success # features/sample.feature:3
Given this step passes # features/step_definitions/steps.rb:1
1 scenario (1 passed)
1 step (1 passed)
"""
Scenario: An AfterStep with one named argument receives only the result
Given a file named "features/support/env.rb" with:
"""
AfterStep do |result|
expect(result).to be_a(Cucumber::Core::Test::Result::Passed)
end
"""
When I run `cucumber features`
Then it should pass with:
"""
Feature: Sample
Scenario: Success # features/sample.feature:3
Given this step passes # features/step_definitions/steps.rb:1
1 scenario (1 passed)
1 step (1 passed)
"""
|