File: state.feature

package info (click to toggle)
cucumber 2.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,076 kB
  • sloc: ruby: 17,016; javascript: 4,641; makefile: 12; sh: 10; tcl: 3
file content (32 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (4)
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