cucumber 1.2.5 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +14 -6
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -0
  5. data/.yardopts +1 -0
  6. data/CONTRIBUTING.md +2 -2
  7. data/History.md +38 -2
  8. data/bin/cucumber +2 -11
  9. data/cucumber.gemspec +3 -3
  10. data/cucumber.yml +5 -1
  11. data/examples/test_unit/Gemfile +4 -0
  12. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +1 -4
  13. data/examples/watir/README.textile +2 -2
  14. data/examples/watir/features/support/env.rb +10 -7
  15. data/features/.cucumber/stepdefs.json +747 -1354
  16. data/features/assertions.feature +6 -2
  17. data/features/background.feature +3 -0
  18. data/features/backtraces.feature +3 -3
  19. data/features/before_hook.feature +43 -0
  20. data/features/bootstrap.feature +14 -2
  21. data/features/custom_formatter.feature +1 -1
  22. data/features/drb_server_integration.feature +3 -3
  23. data/features/formatter_callbacks.feature +2 -2
  24. data/features/formatter_step_file_colon_line.feature +1 -1
  25. data/features/html_formatter.feature +52 -1
  26. data/features/json_formatter.feature +93 -7
  27. data/features/load_path.feature +14 -0
  28. data/features/nested_steps.feature +75 -3
  29. data/features/nested_steps_i18n.feature +36 -0
  30. data/features/pretty_formatter.feature +31 -0
  31. data/features/progress_formatter.feature +31 -0
  32. data/features/raketask.feature +51 -0
  33. data/features/rerun_formatter.feature +1 -1
  34. data/features/stats_formatters.feature +17 -14
  35. data/features/step_definitions/cucumber_steps.rb +6 -4
  36. data/features/support/env.rb +31 -4
  37. data/features/support/feature_factory.rb +17 -0
  38. data/features/tagged_hooks.feature +37 -195
  39. data/features/transforms.feature +15 -15
  40. data/gem_tasks/cucumber.rake +2 -0
  41. data/gem_tasks/yard.rake +10 -6
  42. data/legacy_features/README.md +14 -0
  43. data/legacy_features/language_help.feature +3 -1
  44. data/legacy_features/report_called_undefined_steps.feature +1 -0
  45. data/legacy_features/snippets_when_using_star_keyword.feature +1 -0
  46. data/legacy_features/support/env.rb +4 -0
  47. data/lib/cucumber/ast/background.rb +35 -35
  48. data/lib/cucumber/ast/empty_background.rb +33 -0
  49. data/lib/cucumber/ast/examples.rb +5 -2
  50. data/lib/cucumber/ast/feature.rb +24 -35
  51. data/lib/cucumber/ast/features.rb +4 -1
  52. data/lib/cucumber/ast/has_steps.rb +9 -17
  53. data/lib/cucumber/ast/location.rb +41 -0
  54. data/lib/cucumber/ast/scenario.rb +37 -50
  55. data/lib/cucumber/ast/scenario_outline.rb +62 -49
  56. data/lib/cucumber/ast/step.rb +23 -27
  57. data/lib/cucumber/ast/step_collection.rb +16 -0
  58. data/lib/cucumber/ast/step_invocation.rb +4 -1
  59. data/lib/cucumber/ast/tree_walker.rb +7 -0
  60. data/lib/cucumber/cli/configuration.rb +15 -3
  61. data/lib/cucumber/cli/main.rb +24 -11
  62. data/lib/cucumber/cli/options.rb +24 -16
  63. data/lib/cucumber/configuration.rb +4 -0
  64. data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +10 -34
  65. data/lib/cucumber/core_ext/instance_exec.rb +4 -1
  66. data/lib/cucumber/core_ext/proc.rb +2 -0
  67. data/lib/cucumber/feature_file.rb +5 -12
  68. data/lib/cucumber/formatter/console.rb +10 -0
  69. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +4 -4
  70. data/lib/cucumber/formatter/html.rb +7 -42
  71. data/lib/cucumber/formatter/interceptor.rb +4 -0
  72. data/lib/cucumber/formatter/json_pretty.rb +0 -4
  73. data/lib/cucumber/formatter/junit.rb +8 -2
  74. data/lib/cucumber/formatter/pretty.rb +5 -1
  75. data/lib/cucumber/formatter/progress.rb +4 -0
  76. data/lib/cucumber/formatter/unicode.rb +12 -25
  77. data/lib/cucumber/formatter/usage.rb +7 -2
  78. data/lib/cucumber/js_support/js_snippets.rb +1 -1
  79. data/lib/cucumber/load_path.rb +13 -0
  80. data/lib/cucumber/parser/gherkin_builder.rb +237 -81
  81. data/lib/cucumber/platform.rb +1 -1
  82. data/lib/cucumber/py_support/py_language.rb +1 -1
  83. data/lib/cucumber/rake/task.rb +5 -1
  84. data/lib/cucumber/rb_support/rb_language.rb +20 -19
  85. data/lib/cucumber/rb_support/rb_world.rb +63 -21
  86. data/lib/cucumber/rb_support/snippet.rb +108 -0
  87. data/lib/cucumber/runtime.rb +1 -0
  88. data/lib/cucumber/runtime/support_code.rb +2 -2
  89. data/lib/cucumber/unit.rb +11 -0
  90. data/lib/cucumber/wire_support/wire_language.rb +1 -1
  91. data/spec/cucumber/ast/background_spec.rb +13 -6
  92. data/spec/cucumber/ast/feature_factory.rb +20 -10
  93. data/spec/cucumber/ast/features_spec.rb +51 -0
  94. data/spec/cucumber/ast/scenario_outline_spec.rb +13 -7
  95. data/spec/cucumber/ast/step_spec.rb +6 -4
  96. data/spec/cucumber/cli/configuration_spec.rb +34 -1
  97. data/spec/cucumber/cli/main_spec.rb +36 -26
  98. data/spec/cucumber/cli/options_spec.rb +28 -19
  99. data/spec/cucumber/core_ext/proc_spec.rb +13 -1
  100. data/spec/cucumber/formatter/interceptor_spec.rb +8 -0
  101. data/spec/cucumber/formatter/junit_spec.rb +33 -0
  102. data/spec/cucumber/formatter/pretty_spec.rb +391 -0
  103. data/spec/cucumber/rb_support/rb_language_spec.rb +21 -50
  104. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +2 -4
  105. data/spec/cucumber/rb_support/snippet_spec.rb +128 -0
  106. data/spec/cucumber/step_match_spec.rb +2 -6
  107. metadata +62 -113
  108. data/.rvmrc +0 -1
  109. data/features/hooks.feature +0 -59
  110. data/legacy_features/call_steps_from_stepdefs.feature +0 -154
@@ -26,20 +26,24 @@ Feature: Assertions
26
26
  end
27
27
  """
28
28
 
29
+ @spawn
29
30
  Scenario: Test::Unit
30
31
  Given a file named "features/step_definitions/assert_steps.rb" with:
31
32
  """
33
+ require 'test/unit/assertions'
34
+ World(::Test::Unit::Assertions)
35
+
32
36
  Then /^it should pass$/ do
33
37
  assert(2 + 2 == 4)
34
38
  end
35
39
  """
36
- When I run `ruby -r./without_rspec -S cucumber`
40
+ When I run `cucumber`
37
41
  Then it should pass with exactly:
38
42
  """
39
43
  Feature: Assert
40
44
 
41
45
  Scenario: Passing # features/assert.feature:2
42
- Then it should pass # features/step_definitions/assert_steps.rb:1
46
+ Then it should pass # features/step_definitions/assert_steps.rb:4
43
47
 
44
48
  1 scenario (1 passed)
45
49
  1 step (1 passed)
@@ -278,6 +278,7 @@ Feature: Background
278
278
 
279
279
  """
280
280
 
281
+ @spawn
281
282
  Scenario: run a feature with a background that fails
282
283
  When I run `cucumber -q features/failing_background.feature`
283
284
  Then it should fail with exactly:
@@ -307,6 +308,7 @@ Feature: Background
307
308
 
308
309
  """
309
310
 
311
+ @spawn
310
312
  Scenario: run a feature with scenario outlines that has a background that fails
311
313
  When I run `cucumber -q features/scenario_outline_failing_background.feature`
312
314
  Then it should fail with exactly:
@@ -364,6 +366,7 @@ Feature: Background
364
366
 
365
367
  """
366
368
 
369
+ @spawn
367
370
  Scenario: background passes with first scenario but fails with second
368
371
  When I run `cucumber -q features/failing_background_after_success.feature`
369
372
  Then it should fail with exactly:
@@ -29,8 +29,8 @@ Feature: Backtraces
29
29
 
30
30
  Scenario: Example # features/failing_hard.feature:2
31
31
  Given failing # features/step_definitions/steps.rb:4
32
- java.lang.UnsupportedOperationException: null (NativeException)
33
- java/util/AbstractList.java:131:in `add'
34
- java/util/AbstractList.java:91:in `add'
32
+ (Java::JavaLang::UnsupportedOperationException)
33
+ java.util.AbstractList.add(AbstractList.java:148)
34
+ java.util.AbstractList.add(AbstractList.java:108)
35
35
  """
36
36
 
@@ -0,0 +1,43 @@
1
+ Feature: Before Hook
2
+
3
+ Scenario: Examine names of elements
4
+ Given a file named "features/foo.feature" with:
5
+ """
6
+ Feature: Feature name
7
+
8
+ Scenario: Scenario name
9
+ Given a step
10
+
11
+ Scenario Outline: Scenario Outline name
12
+ Given a <placeholder>
13
+
14
+ Examples: Examples Table name
15
+ | <placeholder> |
16
+ | step |
17
+ """
18
+ And a file named "features/support/hook.rb" with:
19
+ """
20
+ names = []
21
+ Before do |scenario|
22
+ unless scenario.respond_to?(:scenario_outline)
23
+ names << scenario.feature.name.split("\n").first
24
+ names << scenario.name.split("\n").first
25
+ else
26
+ names << scenario.scenario_outline.feature.name.split("\n").first
27
+ names << scenario.scenario_outline.name.split("\n").first
28
+ end
29
+ if(names.size == 4)
30
+ raise "NAMES:\n" + names.join("\n") + "\n"
31
+ end
32
+ end
33
+ """
34
+ When I run `cucumber`
35
+ Then the output should contain:
36
+ """
37
+ NAMES:
38
+ Feature name
39
+ Scenario name
40
+ Feature name
41
+ Scenario Outline name
42
+ """
43
+
@@ -8,6 +8,18 @@ Feature: Bootstrapping a new project
8
8
  When I run `cucumber`
9
9
  Then it should fail with:
10
10
  """
11
- You don't have a 'features' directory. Please create one to get started.
12
- See http://cukes.info/ for more information.
11
+ No such file or directory - features. Please create a features directory to get started. (Errno::ENOENT)
13
12
  """
13
+
14
+ Scenario: does not load ruby files in root if features directory is missing
15
+ Given a directory without standard Cucumber project directory structure
16
+ And a file named "should_not_load.rb" with:
17
+ """
18
+ puts 'this will not be shown'
19
+ """
20
+ When I run `cucumber`
21
+ Then it should fail with exactly:
22
+ """
23
+ No such file or directory - features. Please create a features directory to get started. (Errno::ENOENT)
24
+
25
+ """
@@ -32,7 +32,7 @@ Feature: Custom Formatter
32
32
  end
33
33
  end
34
34
  """
35
- When I run cucumber "features/f.feature --format Ze::Formator"
35
+ When I run `cucumber features/f.feature --format Ze::Formator`
36
36
  Then it should pass with exactly:
37
37
  """
38
38
  I'LL USE MY OWN
@@ -1,4 +1,4 @@
1
- @drb
1
+ @drb @wip-jruby @spawn
2
2
  Feature: DRb Server Integration
3
3
  To prevent waiting for Rails and other large Ruby applications to load their environments
4
4
  for each feature run Cucumber ships with a DRb client that can speak to a server which
@@ -48,7 +48,7 @@ Feature: DRb Server Integration
48
48
 
49
49
  Scenario: Single feature passing with '-r features' option
50
50
  Given I am running spork in the background
51
- When I run cucumber "features/sample.feature -r features --tags ~@wip"
51
+ When I run `cucumber features/sample.feature -r features --tags ~@wip`
52
52
  And it should pass with:
53
53
  """
54
54
  1 step (1 passed)
@@ -56,7 +56,7 @@ Feature: DRb Server Integration
56
56
 
57
57
  Scenario: Single feature passing without '-r features' option
58
58
  Given I am running spork in the background
59
- When I run cucumber "features/sample.feature --tags ~@wip"
59
+ When I run `cucumber features/sample.feature --tags ~@wip`
60
60
  And it should pass with:
61
61
  """
62
62
  1 step (1 passed)
@@ -22,7 +22,7 @@ Feature: Formatter Callback
22
22
  Then /^that|there$/ do
23
23
  end
24
24
  """
25
- When I run cucumber "features/f.feature --format debug"
25
+ When I run `cucumber features/f.feature --format debug`
26
26
  Then it should pass with exactly:
27
27
  """
28
28
  before_features
@@ -117,7 +117,7 @@ Feature: Formatter Callback
117
117
  Then /^that|there$/ do
118
118
  end
119
119
  """
120
- When I run cucumber "features/f.feature --format debug --expand"
120
+ When I run `cucumber features/f.feature --format debug --expand`
121
121
  Then it should pass with exactly:
122
122
  """
123
123
  before_features
@@ -35,7 +35,7 @@ Feature: Formatter API: Step file path and line number (Issue #179)
35
35
  end
36
36
  end
37
37
  """
38
- When I run cucumber "features/f.feature --format Jb::Formatter"
38
+ When I run `cucumber features/f.feature --format Jb::Formatter`
39
39
  Then it should pass with exactly:
40
40
  """
41
41
  step result event: features/f.feature:4
@@ -12,8 +12,59 @@ Feature: HTML output formatter
12
12
  |foo|
13
13
  |bar|
14
14
  """
15
+ And a file named "features/scenario_outline_with_pending_step.feature" with:
16
+ """
17
+ Feature: Outline
18
+
19
+ Scenario Outline: Will it blend?
20
+ Given this hasn't been implemented yet
21
+ And other step
22
+ When I do something with <example>
23
+ Then I should see something
24
+ Examples:
25
+ | example |
26
+ | one |
27
+ | two |
28
+ | three |
29
+ """
30
+ And a file named "features/step_definitions/steps.rb" with:
31
+ """
32
+ Given /^this hasn't been implemented yet$/ do
33
+ pending
34
+ end
35
+ """
15
36
 
16
37
  Scenario: an scenario outline, one undefined step, one random example, expand flag on
17
- When I run cucumber "features/scenario_outline_with_undefined_steps.feature --format html --expand "
38
+ When I run `cucumber features/scenario_outline_with_undefined_steps.feature --format html --expand `
39
+ Then it should pass
40
+
41
+ Scenario Outline: an scenario outline, one pending step
42
+ When I run `cucumber <file> --format html <flag>`
43
+ Then it should pass
44
+ And the output should contain:
45
+ """
46
+ makeYellow('scenario_1')
47
+ """
48
+ And the output should not contain:
49
+ """
50
+ makeRed('scenario_1')
51
+ """
52
+ Examples:
53
+ | file | flag |
54
+ | features/scenario_outline_with_pending_step.feature | --expand |
55
+ | features/scenario_outline_with_pending_step.feature | |
56
+ | features/scenario_outline_with_undefined_steps.feature | --expand |
57
+ | features/scenario_outline_with_undefined_steps.feature | |
58
+
59
+ Scenario: when using a profile the html shouldn't include 'Using the default profile...'
60
+ And a file named "cucumber.yml" with:
61
+ """
62
+ default: -r features
63
+ """
64
+ When I run `cucumber --profile default --format html`
18
65
  Then it should pass
66
+ And the output should not contain:
67
+ """
68
+ Using the default profile...
69
+ """
19
70
 
@@ -60,8 +60,10 @@ Feature: JSON output formatter
60
60
 
61
61
  """
62
62
 
63
+ # Need to investigate why this won't pass in-process. error_message doesn't get det?
64
+ @spawn
63
65
  Scenario: one feature, one passing scenario, one failing scenario
64
- When I run cucumber "--format json features/one_passing_one_failing.feature"
66
+ When I run `cucumber --format json features/one_passing_one_failing.feature`
65
67
  Then it should fail with JSON:
66
68
  """
67
69
  [
@@ -142,12 +144,96 @@ Feature: JSON output formatter
142
144
 
143
145
  """
144
146
 
147
+ @spawn
148
+ Scenario: one feature, one passing scenario, one failing scenario with prettyfied json
149
+ When I run `cucumber --format json_pretty features/one_passing_one_failing.feature`
150
+ Then it should fail with JSON:
151
+ """
152
+ [
153
+ {
154
+ "uri": "features/one_passing_one_failing.feature",
155
+ "keyword": "Feature",
156
+ "id": "one-passing-scenario,-one-failing-scenario",
157
+ "name": "One passing scenario, one failing scenario",
158
+ "line": 2,
159
+ "description": "",
160
+ "tags": [
161
+ {
162
+ "name": "@a",
163
+ "line": 1
164
+ }
165
+ ],
166
+ "elements": [
167
+ {
168
+ "keyword": "Scenario",
169
+ "id": "one-passing-scenario,-one-failing-scenario;passing",
170
+ "name": "Passing",
171
+ "line": 5,
172
+ "description": "",
173
+ "tags": [
174
+ {
175
+ "name": "@b",
176
+ "line": 4
177
+ }
178
+ ],
179
+ "type": "scenario",
180
+ "steps": [
181
+ {
182
+ "keyword": "Given ",
183
+ "name": "a passing step",
184
+ "line": 6,
185
+ "match": {
186
+ "location": "features/step_definitions/steps.rb:1"
187
+ },
188
+ "result": {
189
+ "status": "passed",
190
+ "duration": 1
191
+ }
192
+ }
193
+ ]
194
+ },
195
+ {
196
+ "keyword": "Scenario",
197
+ "id": "one-passing-scenario,-one-failing-scenario;failing",
198
+ "name": "Failing",
199
+ "line": 9,
200
+ "description": "",
201
+ "tags": [
202
+ {
203
+ "name": "@c",
204
+ "line": 8
205
+ }
206
+ ],
207
+ "type": "scenario",
208
+ "steps": [
209
+ {
210
+ "keyword": "Given ",
211
+ "name": "a failing step",
212
+ "line": 10,
213
+ "match": {
214
+ "location": "features/step_definitions/steps.rb:5"
215
+ },
216
+ "result": {
217
+ "status": "failed",
218
+ "error_message": " (RuntimeError)\n./features/step_definitions/steps.rb:6:in `/a failing step/'\nfeatures/one_passing_one_failing.feature:10:in `Given a failing step'",
219
+ "duration": 1
220
+ }
221
+ }
222
+ ]
223
+ }
224
+ ]
225
+ }
226
+ ]
227
+
228
+ """
229
+
230
+ @spawn
145
231
  Scenario: DocString
146
232
  Given a file named "features/doc_string.feature" with:
147
233
  """
148
234
  Feature: A DocString feature
149
235
 
150
- Scenario:
236
+ Scenario:
151
237
  Then I should fail with
152
238
  \"\"\"
153
239
  a string
@@ -159,7 +245,7 @@ Feature: JSON output formatter
159
245
  raise s
160
246
  end
161
247
  """
162
- When I run cucumber "--format json features/doc_string.feature"
248
+ When I run `cucumber --format json features/doc_string.feature`
163
249
  Then it should fail with JSON:
164
250
  """
165
251
  [
@@ -184,8 +270,8 @@ Feature: JSON output formatter
184
270
  "name": "I should fail with",
185
271
  "line": 4,
186
272
  "doc_string": {
187
- "content_type": "",
188
- "value": "a string",
273
+ "content_type": "",
274
+ "value": "a string",
189
275
  "line": 5
190
276
  },
191
277
  "match": {
@@ -203,9 +289,9 @@ Feature: JSON output formatter
203
289
  }
204
290
  ]
205
291
  """
206
-
292
+ @wip-jruby
207
293
  Scenario: embedding screenshot
208
- When I run cucumber "-b --format json features/embed.feature"
294
+ When I run `cucumber -b --format json features/embed.feature`
209
295
  Then it should pass with JSON:
210
296
  """
211
297
  [
@@ -0,0 +1,14 @@
1
+ Feature: Set up a default load path
2
+
3
+ Scenario: ./lib is included in the $LOAD_PATH
4
+ Given a file named "features/support/env.rb" with:
5
+ """
6
+ require 'something'
7
+ """
8
+ And a file named "lib/something.rb" with:
9
+ """
10
+ class Something
11
+ end
12
+ """
13
+ When I run `cucumber`
14
+ Then it should pass
@@ -49,12 +49,84 @@ Feature: Nested Steps
49
49
 
50
50
  """
51
51
 
52
- Scenario: Use deprecated i18n methods
52
+ Scenario: Use #steps to call a table
53
+ Given a step definition that looks like this:
54
+ """ruby
55
+ Given /turtles:/ do |table|
56
+ table.hashes.each do |row|
57
+ puts row[:name]
58
+ end
59
+ end
60
+ """
61
+ And a step definition that looks like this:
62
+ """ruby
63
+ Given /two turtles/ do
64
+ steps %{
65
+ Given turtles:
66
+ | name |
67
+ | Sturm |
68
+ | Liouville |
69
+ }
70
+ end
71
+ """
72
+ When I run the feature with the progress formatter
73
+ Then the output should contain:
74
+ """
75
+ Sturm
76
+
77
+ Liouville
78
+
79
+ """
80
+
81
+ Scenario: Use #steps to call a multi-line string
82
+ Given a step definition that looks like this:
83
+ """ruby
84
+ Given /two turtles/ do
85
+ steps %Q{
86
+ Given turtles:
87
+ \"\"\"
88
+ Sturm
89
+ Liouville
90
+ \"\"\"
91
+ }
92
+ end
93
+ """
94
+ And a step definition that looks like this:
95
+ """ruby
96
+ Given /turtles:/ do |string|
97
+ puts string
98
+ end
99
+ """
100
+ When I run the feature with the progress formatter
101
+ Then the output should contain:
102
+ """
103
+ Sturm
104
+ Liouville
105
+ """
106
+
107
+ @spawn
108
+ Scenario: Backtrace doesn't skip nested steps
53
109
  Given a step definition that looks like this:
54
110
  """ruby
55
111
  Given /two turtles/ do
56
- Given "a turtle"
112
+ step "I have a couple turtles"
113
+ end
114
+
115
+ When /I have a couple turtles/ do
116
+ raise 'error'
57
117
  end
58
118
  """
59
119
  When I run the feature with the progress formatter
60
- Then the output should contain "WARNING"
120
+ Then it should fail with:
121
+ """
122
+ error (RuntimeError)
123
+ ./features/step_definitions/test_steps2.rb:6:in `/I have a couple turtles/'
124
+ ./features/step_definitions/test_steps2.rb:2:in `/two turtles/'
125
+ features/test_feature_1.feature:3:in `Given two turtles'
126
+
127
+ Failing Scenarios:
128
+ cucumber features/test_feature_1.feature:2 # Scenario: Test Scenario 1
129
+
130
+ 1 scenario (1 failed)
131
+ 1 step (1 failed)
132
+ """