josephwilk (owner)

Revisions

gist: 52506 Download_button fork
public
Public Clone URL: git://gist.github.com/52506.git
Embed All Files: show embed
background.feature #
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Feature: backgrounds
  In order to provide a context to my scenarios within a feature
  As a feature editor
  I want to write a background section in my features.
  
  Scenario: run a feature with a background that passes
    When I run cucumber -q features/passing_background.feature
    Then it should pass with
    """
    Feature: sample
 
      Background:
        Given '10' cukes
      Scenario: passing background
        Then I should have '10' cukes
 
      Scenario: another passing background
        Then I should have '10' cukes
 
    2 scenarios
    4 steps passed
    
    """
 
  Scenario: run a feature with scenario outlines that has a background that passes
    When I run cucumber -q features/scenario_outline_passing_background.feature
    Then it should pass with
    """
    Feature: sample
 
      Background:
        Given '10' cukes
      Scenario Outline: passing background
        Then I should have '<count>' cukes
 
      Examples:
        | count |
        | 10 |
 
      Scenario Outline: another passing background
        Then I should have '<count>' cukes
 
      Examples:
        | count |
        | 10 |
 
    2 scenarios
    4 steps passed
 
    """
 
  Scenario: run a scenario with a background with a failing step
    When I run cucumber -q features/failing_background.feature
    Then it should fail with
    """
    Feature: sample
 
      Background:
        Given failing without a table
          FAIL (RuntimeError)
          ./features/step_definitions/sample_steps.rb:4:in `/^failing without a table$/'
          features/failing_background.feature:4:in `Given failing without a table'
      Scenario: failing background
        Then I should have '10' cukes
 
      Scenario: another failing background
        Then I should have '10' cukes
 
    2 scenarios
    2 steps failed
    2 steps skipped
 
    """
 
  Scenario: run a scenario outline with a background that fails
    When I run cucumber -q features/scenario_outline_failing_background.feature
    Then it should fail with
    """
    Feature: sample
 
      Background:
        Given failing without a table
          FAIL (RuntimeError)
          ./features/step_definitions/sample_steps.rb:4:in `/^failing without a table$/'
          features/scenario_outline_failing_background.feature:4:in `Given failing without a table'
      Scenario Outline: passing background
        Then I should have '<count>' cukes
 
      Examples:
        | count |
        | 10 |
 
      Scenario Outline: another passing background
        Then I should have '<count>' cukes
 
      Examples:
        | count |
        | 10 |
 
    2 scenarios
    2 steps failed
    2 steps skipped
 
    """
 
  Scenario: run a feature with a background that is pending
    When I run cucumber -q features/pending_background.feature
    Then it should pass with
    """
    Feature: sample
 
      Background:
        Given pending
      Scenario: passing background
        Then I should have '10' cukes
 
      Scenario: another passing background
        Then I should have '10' cukes
 
    2 scenarios
    2 steps skipped
    2 steps undefined
 
    """
 
  Scenario: background passes with first scenario but fails with second
    When I run cucumber -q features/failing_background_after_success.feature
    Then it should fail with
    """
    Feature: sample
 
      Background:
        Given '10' global cukes
      Scenario: passing background
        Then I should have '10' global cukes
 
      Background:
        Given '10' global cukes
          FAIL (RuntimeError)
          ./features/step_definitions/sample_steps.rb:4:in `/^'(.+)' global cukes$/'
          features/failing_background_after_success.feature:3:in `Given '10' global cukes'
      Scenario: another passing background
        Then I should have '10' global cukes
 
    2 scenarios
    1 step failed
    1 step skipped
    2 steps passed
 
    """
 
  Scenario: run a scenario showing explicit background steps --explicit-background