cucumber 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -0
  3. data/Gemfile +3 -1
  4. data/History.md +18 -2
  5. data/README.md +5 -1
  6. data/cucumber.gemspec +3 -4
  7. data/cucumber.yml +2 -2
  8. data/features/docs/api/run_cli_main_with_existing_runtime.feature +4 -7
  9. data/features/docs/defining_steps/skip_scenario.feature +6 -2
  10. data/features/docs/formatters/api_methods.feature +36 -0
  11. data/features/docs/profiles.feature +2 -2
  12. data/features/lib/step_definitions/profile_steps.rb +1 -1
  13. data/lib/cucumber.rb +11 -4
  14. data/lib/cucumber/cli/configuration.rb +2 -2
  15. data/lib/cucumber/cli/options.rb +2 -2
  16. data/lib/cucumber/configuration.rb +25 -3
  17. data/lib/cucumber/deprecate.rb +29 -0
  18. data/lib/cucumber/filters/activate_steps.rb +39 -5
  19. data/lib/cucumber/formatter/console.rb +4 -4
  20. data/lib/cucumber/formatter/io.rb +1 -1
  21. data/lib/cucumber/formatter/legacy_api/adapter.rb +30 -30
  22. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +4 -9
  23. data/lib/cucumber/platform.rb +2 -7
  24. data/lib/cucumber/rb_support/rb_language.rb +72 -26
  25. data/lib/cucumber/rb_support/rb_step_definition.rb +2 -2
  26. data/lib/cucumber/rb_support/rb_world.rb +6 -1
  27. data/lib/cucumber/rb_support/snippet.rb +21 -0
  28. data/lib/cucumber/running_test_case.rb +5 -1
  29. data/lib/cucumber/runtime.rb +11 -15
  30. data/lib/cucumber/runtime/support_code.rb +20 -128
  31. data/lib/cucumber/step_argument.rb +25 -0
  32. data/lib/cucumber/step_match.rb +6 -12
  33. data/lib/cucumber/step_match_search.rb +67 -0
  34. data/lib/cucumber/version +1 -0
  35. data/spec/cucumber/configuration_spec.rb +3 -2
  36. data/spec/cucumber/filters/activate_steps_spec.rb +95 -3
  37. data/spec/cucumber/formatter/html_spec.rb +1 -1
  38. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +55 -28
  39. data/spec/cucumber/formatter/pretty_spec.rb +2 -2
  40. data/spec/cucumber/formatter/spec_helper.rb +22 -12
  41. data/spec/cucumber/rb_support/rb_language_spec.rb +9 -45
  42. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +2 -2
  43. data/spec/cucumber/rb_support/rb_world_spec.rb +47 -0
  44. data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -1
  45. data/spec/cucumber/runtime/support_code_spec.rb +4 -111
  46. data/spec/cucumber/step_argument_spec.rb +18 -0
  47. data/spec/cucumber/step_match_search_spec.rb +122 -0
  48. data/spec/cucumber/step_match_spec.rb +8 -2
  49. data/spec/cucumber/world/pending_spec.rb +2 -1
  50. data/spec/cucumber_spec.rb +39 -0
  51. metadata +45 -50
  52. data/features/docs/wire_protocol/erb_configuration.feature +0 -56
  53. data/features/docs/wire_protocol/handle_unexpected_response.feature +0 -30
  54. data/features/docs/wire_protocol/invoke_message.feature +0 -216
  55. data/features/docs/wire_protocol/readme.md +0 -26
  56. data/features/docs/wire_protocol/snippets_message.feature +0 -51
  57. data/features/docs/wire_protocol/step_matches_message.feature +0 -81
  58. data/features/docs/wire_protocol/table_diffing.feature +0 -126
  59. data/features/docs/wire_protocol/tags.feature +0 -87
  60. data/features/docs/wire_protocol/timeouts.feature +0 -64
  61. data/lib/cucumber/events/bus.rb +0 -86
  62. data/lib/cucumber/gherkin/formatter/argument.rb +0 -17
  63. data/lib/cucumber/gherkin/formatter/hashable.rb +0 -27
  64. data/lib/cucumber/language_support.rb +0 -30
  65. data/lib/cucumber/language_support/language_methods.rb +0 -72
  66. data/lib/cucumber/rb_support/regexp_argument_matcher.rb +0 -21
  67. data/lib/cucumber/wire_support/configuration.rb +0 -38
  68. data/lib/cucumber/wire_support/connection.rb +0 -61
  69. data/lib/cucumber/wire_support/request_handler.rb +0 -32
  70. data/lib/cucumber/wire_support/wire_exception.rb +0 -32
  71. data/lib/cucumber/wire_support/wire_language.rb +0 -68
  72. data/lib/cucumber/wire_support/wire_packet.rb +0 -34
  73. data/lib/cucumber/wire_support/wire_protocol.rb +0 -43
  74. data/lib/cucumber/wire_support/wire_protocol/requests.rb +0 -133
  75. data/lib/cucumber/wire_support/wire_step_definition.rb +0 -21
  76. data/spec/cucumber/events/bus_spec.rb +0 -94
  77. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +0 -22
  78. data/spec/cucumber/wire_support/configuration_spec.rb +0 -64
  79. data/spec/cucumber/wire_support/connection_spec.rb +0 -64
  80. data/spec/cucumber/wire_support/wire_exception_spec.rb +0 -50
  81. data/spec/cucumber/wire_support/wire_language_spec.rb +0 -46
  82. data/spec/cucumber/wire_support/wire_packet_spec.rb +0 -44
@@ -1,56 +0,0 @@
1
- @wire
2
- Feature: ERB configuration
3
-
4
- As a developer on server with multiple users
5
- I want to be able to configure which port my wire server runs on
6
- So that I can avoid port conflicts
7
-
8
- Background:
9
- Given a file named "features/wired.feature" with:
10
- """
11
- Feature: High strung
12
- Scenario: Wired
13
- Given we're all wired
14
-
15
- """
16
-
17
- Scenario: ERB is used in the wire file which references an environment variable that is not set
18
- Given a file named "features/step_definitions/server.wire" with:
19
- """
20
- host: localhost
21
- port: <%= ENV['PORT'] || 12345 %>
22
- """
23
- And there is a wire server running on port 12345 which understands the following protocol:
24
- | request | response |
25
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
26
- When I run `cucumber --dry-run --no-snippets -f progress`
27
- Then it should pass with:
28
- """
29
- U
30
-
31
- 1 scenario (1 undefined)
32
- 1 step (1 undefined)
33
-
34
- """
35
-
36
-
37
- Scenario: ERB is used in the wire file which references an environment variable
38
- Given I have environment variable PORT set to "16816"
39
- And a file named "features/step_definitions/server.wire" with:
40
- """
41
- host: localhost
42
- port: <%= ENV['PORT'] || 12345 %>
43
- """
44
- And there is a wire server running on port 16816 which understands the following protocol:
45
- | request | response |
46
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
47
- When I run `cucumber --dry-run --no-snippets -f progress`
48
- Then it should pass with:
49
- """
50
- U
51
-
52
- 1 scenario (1 undefined)
53
- 1 step (1 undefined)
54
-
55
- """
56
-
@@ -1,30 +0,0 @@
1
- @wire
2
- Feature: Handle unexpected response
3
-
4
- When the server sends us back a message we don't understand, this is how Cucumber will behave.
5
-
6
- Background:
7
- Given a file named "features/wired.feature" with:
8
- """
9
- Feature: High strung
10
- Scenario: Wired
11
- Given we're all wired
12
-
13
- """
14
- And a file named "features/step_definitions/some_remote_place.wire" with:
15
- """
16
- host: localhost
17
- port: 54321
18
-
19
- """
20
-
21
- Scenario: Unexpected response
22
- Given there is a wire server running on port 54321 which understands the following protocol:
23
- | request | response |
24
- | ["begin_scenario"] | ["yikes"] |
25
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
26
- When I run `cucumber -f pretty`
27
- Then the output should contain:
28
- """
29
- undefined method `handle_yikes'
30
- """
@@ -1,216 +0,0 @@
1
- @wire
2
- Feature: Invoke message
3
-
4
- Assuming a StepMatch was returned for a given step name, when it's time to
5
- invoke that step definition, Cucumber will send an invoke message.
6
-
7
- The invoke message contains the ID of the step definition, as returned by
8
- the wire server in response to the the step_matches call, along with the
9
- arguments that were parsed from the step name during the same step_matches
10
- call.
11
-
12
- The wire server will normally reply one of the following:
13
-
14
- * `success`
15
- * `fail`
16
- * `pending` - optionally takes a message argument
17
-
18
- This isn't quite the whole story: see also table_diffing.feature
19
-
20
- Background:
21
- Given a file named "features/wired.feature" with:
22
- """
23
- Feature: High strung
24
- Scenario: Wired
25
- Given we're all wired
26
-
27
- """
28
- And a file named "features/step_definitions/some_remote_place.wire" with:
29
- """
30
- host: localhost
31
- port: 54321
32
-
33
- """
34
-
35
-
36
- @spawn
37
- Scenario: Invoke a step definition which is pending
38
- Given there is a wire server running on port 54321 which understands the following protocol:
39
- | request | response |
40
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
41
- | ["begin_scenario"] | ["success"] |
42
- | ["invoke",{"id":"1","args":[]}] | ["pending", "I'll do it later"] |
43
- | ["end_scenario"] | ["success"] |
44
- When I run `cucumber -f pretty -q`
45
- And it should pass with:
46
- """
47
- Feature: High strung
48
-
49
- Scenario: Wired
50
- Given we're all wired
51
- I'll do it later (Cucumber::Pending)
52
- features/wired.feature:3:in `Given we're all wired'
53
-
54
- 1 scenario (1 pending)
55
- 1 step (1 pending)
56
-
57
- """
58
-
59
- Scenario: Invoke a step definition which passes
60
- Given there is a wire server running on port 54321 which understands the following protocol:
61
- | request | response |
62
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
63
- | ["begin_scenario"] | ["success"] |
64
- | ["invoke",{"id":"1","args":[]}] | ["success"] |
65
- | ["end_scenario"] | ["success"] |
66
- When I run `cucumber -f progress`
67
- And it should pass with:
68
- """
69
- .
70
-
71
- 1 scenario (1 passed)
72
- 1 step (1 passed)
73
-
74
- """
75
-
76
- @spawn
77
- Scenario: Invoke a step definition which fails
78
-
79
- If an invoked step definition fails, it can return details of the exception
80
- in the reply to invoke. This causes a Cucumber::WireSupport::WireException to be
81
- raised.
82
-
83
- Valid arguments are:
84
-
85
- - `message` (mandatory)
86
- - `exception`
87
- - `backtrace`
88
-
89
- See the specs for Cucumber::WireSupport::WireException for more details
90
-
91
- Given there is a wire server running on port 54321 which understands the following protocol:
92
- | request | response |
93
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
94
- | ["begin_scenario"] | ["success"] |
95
- | ["invoke",{"id":"1","args":[]}] | ["fail",{"message":"The wires are down", "exception":"Some.Foreign.ExceptionType"}] |
96
- | ["end_scenario"] | ["success"] |
97
- When I run `cucumber -f progress`
98
- Then the stderr should not contain anything
99
- And it should fail with:
100
- """
101
- F
102
-
103
- (::) failed steps (::)
104
-
105
- The wires are down (Some.Foreign.ExceptionType from localhost:54321)
106
- features/wired.feature:3:in `Given we're all wired'
107
-
108
- Failing Scenarios:
109
- cucumber features/wired.feature:2 # Scenario: Wired
110
-
111
- 1 scenario (1 failed)
112
- 1 step (1 failed)
113
-
114
- """
115
-
116
- Scenario: Invoke a step definition which takes string arguments (and passes)
117
-
118
- If the step definition at the end of the wire captures arguments, these are
119
- communicated back to Cucumber in the `step_matches` message.
120
-
121
- Cucumber expects these StepArguments to be returned in the StepMatch. The keys
122
- have the following meanings:
123
-
124
- - `val` - the value of the string captured for that argument from the step
125
- name passed in step_matches
126
- - `pos` - the position within the step name that the argument was matched
127
- (used for formatter highlighting)
128
-
129
- The argument values are then sent back by Cucumber in the `invoke` message.
130
-
131
- Given there is a wire server running on port 54321 which understands the following protocol:
132
- | request | response |
133
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[{"val":"wired", "pos":10}]}]] |
134
- | ["begin_scenario"] | ["success"] |
135
- | ["invoke",{"id":"1","args":["wired"]}] | ["success"] |
136
- | ["end_scenario"] | ["success"] |
137
- When I run `cucumber -f progress`
138
- Then the stderr should not contain anything
139
- And it should pass with:
140
- """
141
- .
142
-
143
- 1 scenario (1 passed)
144
- 1 step (1 passed)
145
-
146
- """
147
-
148
- Scenario: Invoke a step definition which takes regular and table arguments (and passes)
149
-
150
- If the step has a multiline table argument, it will be passed with the
151
- invoke message as an array of array of strings.
152
-
153
- In this scenario our step definition takes two arguments - one
154
- captures the "we're" and the other takes the table.
155
-
156
- Given a file named "features/wired_on_tables.feature" with:
157
- """
158
- Feature: High strung
159
- Scenario: Wired and more
160
- Given we're all:
161
- | wired |
162
- | high |
163
- | happy |
164
- """
165
- And there is a wire server running on port 54321 which understands the following protocol:
166
- | request | response |
167
- | ["step_matches",{"name_to_match":"we're all:"}] | ["success",[{"id":"1", "args":[{"val":"we're", "pos":0}]}]] |
168
- | ["begin_scenario"] | ["success"] |
169
- | ["invoke",{"id":"1","args":["we're",[["wired"],["high"],["happy"]]]}] | ["success"] |
170
- | ["end_scenario"] | ["success"] |
171
- When I run `cucumber -f progress features/wired_on_tables.feature`
172
- Then the stderr should not contain anything
173
- And it should pass with:
174
- """
175
- .
176
-
177
- 1 scenario (1 passed)
178
- 1 step (1 passed)
179
-
180
- """
181
-
182
- Scenario: Invoke a scenario outline step
183
- Given a file named "features/wired_in_an_outline.feature" with:
184
- """
185
- Feature:
186
- Scenario Outline:
187
- Given we're all <arg>
188
-
189
- Examples:
190
- | arg |
191
- | wired |
192
- """
193
- And there is a wire server running on port 54321 which understands the following protocol:
194
- | request | response |
195
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
196
- | ["begin_scenario"] | ["success"] |
197
- | ["invoke",{"id":"1","args":[]}] | ["success"] |
198
- | ["end_scenario"] | ["success"] |
199
- When I run `cucumber -f progress features/wired_in_an_outline.feature`
200
- Then the stderr should not contain anything
201
- And it should pass with:
202
- """
203
- .
204
-
205
- 1 scenario (1 passed)
206
- 1 step (1 passed)
207
-
208
- """
209
- And the wire server should have received the following messages:
210
- | step_matches |
211
- | begin_scenario |
212
- | invoke |
213
- | end_scenario |
214
-
215
-
216
-
@@ -1,26 +0,0 @@
1
- Cucumber's wire protocol allows step definitions to be
2
- implemented and invoked on any platform.
3
-
4
- Communication is over a TCP socket, which Cucumber connects to when it finds
5
- a definition file with the .wire extension in the step_definitions folder
6
- (or other load path). Note that these files are rendered with ERB when loaded.
7
-
8
- A WirePacket flowing in either direction is formatted as a JSON-encoded
9
- string, with a newline character signaling the end of a packet. See the
10
- specs for Cucumber::WireSupport::WirePacket for more details.
11
-
12
- Cucumber sends the following request messages out over the wire:
13
-
14
- * `step_matches` - Find out whether the wire server has a definition for a step
15
- * `invoke` - Ask for a step definition to be invoked
16
- * `begin_scenario` - signals that cucumber is about to execute a scenario
17
- * `end_scenario` - signals that cucumber has finished executing a scenario
18
- * `snippet_text` - requests a snippet for an undefined step
19
-
20
- Every message supports two standard responses:
21
-
22
- * `success` - expects different arguments (sometimes none at all) depending
23
- on the request that was sent.
24
- * `fail` - causes a Cucumber::WireSupport::WireException to be raised.
25
-
26
- Some messages support more responses - see individual scenarios for details.
@@ -1,51 +0,0 @@
1
- @wire
2
- Feature: Snippets message
3
-
4
- If a step doesn't match, Cucumber will ask the wire server to return a snippet of code for a
5
- step definition.
6
-
7
- Background:
8
- Given a file named "features/wired.feature" with:
9
- """
10
- Feature: High strung
11
- Scenario: Wired
12
- Given we're all wired
13
-
14
- """
15
- And a file named "features/step_definitions/some_remote_place.wire" with:
16
- """
17
- host: localhost
18
- port: 54321
19
-
20
- """
21
-
22
- @spawn
23
- Scenario: Wire server returns snippets for a step that didn't match
24
- Given there is a wire server running on port 54321 which understands the following protocol:
25
- | request | response |
26
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
27
- | ["snippet_text",{"step_keyword":"Given","multiline_arg_class":"","step_name":"we're all wired"}] | ["success","foo()\n bar;\nbaz"] |
28
- | ["begin_scenario"] | ["success"] |
29
- | ["end_scenario"] | ["success"] |
30
- When I run `cucumber -f pretty`
31
- Then the stderr should not contain anything
32
- And it should pass with:
33
- """
34
- Feature: High strung
35
-
36
- Scenario: Wired # features/wired.feature:2
37
- Given we're all wired # features/wired.feature:3
38
-
39
- 1 scenario (1 undefined)
40
- 1 step (1 undefined)
41
- """
42
- And the output should contain:
43
- """
44
-
45
- You can implement step definitions for undefined steps with these snippets:
46
-
47
- foo()
48
- bar;
49
- baz
50
-
51
- """
@@ -1,81 +0,0 @@
1
- @wire
2
- Feature: Step matches message
3
-
4
- When the features have been parsed, Cucumber will send a `step_matches`
5
- message to ask the wire server if it can match a step name. This happens for
6
- each of the steps in each of the features.
7
-
8
- The wire server replies with an array of StepMatch objects.
9
-
10
- When each StepMatch is returned, it contains the following data:
11
-
12
- * `id` - identifier for the step definition to be used later when if it
13
- needs to be invoked. The identifier can be any string value and
14
- is simply used for the wire server's own reference.
15
- * `args` - any argument values as captured by the wire end's own regular
16
- expression (or other argument matching) process.
17
-
18
- Background:
19
- Given a file named "features/wired.feature" with:
20
- """
21
- Feature: High strung
22
- Scenario: Wired
23
- Given we're all wired
24
-
25
- """
26
- And a file named "features/step_definitions/some_remote_place.wire" with:
27
- """
28
- host: localhost
29
- port: 54321
30
-
31
- """
32
-
33
- Scenario: Dry run finds no step match
34
- Given there is a wire server running on port 54321 which understands the following protocol:
35
- | request | response |
36
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
37
- When I run `cucumber --dry-run --no-snippets -f progress`
38
- And it should pass with:
39
- """
40
- U
41
-
42
- 1 scenario (1 undefined)
43
- 1 step (1 undefined)
44
-
45
- """
46
-
47
- Scenario: Dry run finds a step match
48
- Given there is a wire server running on port 54321 which understands the following protocol:
49
- | request | response |
50
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
51
- When I run `cucumber --dry-run -f progress`
52
- And it should pass with:
53
- """
54
- -
55
-
56
- 1 scenario (1 skipped)
57
- 1 step (1 skipped)
58
-
59
- """
60
-
61
- Scenario: Step matches returns details about the remote step definition
62
-
63
- Optionally, the StepMatch can also contain a source reference, and a native
64
- regexp string which will be used by some formatters.
65
-
66
- Given there is a wire server running on port 54321 which understands the following protocol:
67
- | request | response |
68
- | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[], "source":"MyApp.MyClass:123", "regexp":"we.*"}]] |
69
- When I run `cucumber -f stepdefs --dry-run`
70
- Then it should pass with:
71
- """
72
- -
73
-
74
- we.* # MyApp.MyClass:123
75
-
76
- 1 scenario (1 skipped)
77
- 1 step (1 skipped)
78
-
79
- """
80
- And the stderr should not contain anything
81
-