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
|
Feature: State
You can pass state between step by setting instance variables,
but those instance variables will be gone when the next scenario runs.
Scenario: Set an ivar in one scenario, use it in the next step
Given a file named "features/test.feature" with:
"""
Feature:
Scenario:
Given I have set @flag = true
Then @flag should be true
Scenario:
Then @flag should be nil
"""
And a file named "features/step_definitions/steps.rb" with:
"""
Given /set @flag/ do
@flag = true
end
Then /flag should be true/ do
expect(@flag).to be_truthy
end
Then /flag should be nil/ do
expect(@flag).to be_nil
end
"""
When I run `cucumber`
Then it should pass
|