cucumber 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/.rspec +1 -1
  2. data/Caliper.yml +4 -0
  3. data/History.txt +1557 -0
  4. data/LICENSE +1 -1
  5. data/README.rdoc +26 -0
  6. data/Rakefile +51 -5
  7. data/VERSION.yml +5 -0
  8. data/bin/cucumber +1 -7
  9. data/cucumber.gemspec +77 -3
  10. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
  11. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
  12. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +7 -4
  13. data/examples/i18n/ro/features/suma.feature +11 -0
  14. data/examples/i18n/ru/features/division.feature +2 -2
  15. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
  16. data/examples/sinatra/features/support/env.rb +5 -2
  17. data/examples/v8/features/fibonacci.feature +1 -1
  18. data/examples/watir/features/step_definitions/search_steps.rb +1 -1
  19. data/features/announce.feature +164 -0
  20. data/features/around_hooks.feature +232 -0
  21. data/features/background.feature +95 -284
  22. data/features/bug_371.feature +32 -0
  23. data/features/bug_464.feature +16 -0
  24. data/features/bug_475.feature +42 -0
  25. data/features/bug_585_tab_indentation.feature +22 -0
  26. data/features/bug_600.feature +67 -0
  27. data/features/call_steps_from_stepdefs.feature +154 -0
  28. data/features/cucumber_cli.feature +591 -0
  29. data/features/cucumber_cli_outlines.feature +117 -0
  30. data/features/custom_formatter.feature +73 -3
  31. data/features/default_snippets.feature +42 -0
  32. data/features/diffing.feature +25 -0
  33. data/features/drb_server_integration.feature +174 -0
  34. data/features/exception_in_after_block.feature +127 -0
  35. data/features/exception_in_after_step_block.feature +104 -0
  36. data/features/exception_in_before_block.feature +98 -0
  37. data/features/exclude_files.feature +20 -0
  38. data/features/expand.feature +60 -0
  39. data/features/html_formatter.feature +8 -0
  40. data/features/html_formatter/a.html +582 -0
  41. data/features/json_formatter.feature +245 -160
  42. data/features/junit_formatter.feature +88 -0
  43. data/features/language_from_header.feature +30 -0
  44. data/features/language_help.feature +78 -0
  45. data/features/listener_debugger_formatter.feature +42 -0
  46. data/features/multiline_names.feature +44 -0
  47. data/features/negative_tagged_hooks.feature +60 -0
  48. data/features/post_configuration_hook.feature +37 -0
  49. data/features/profiles.feature +126 -0
  50. data/features/rake_task.feature +152 -0
  51. data/features/report_called_undefined_steps.feature +34 -0
  52. data/features/rerun_formatter.feature +45 -0
  53. data/features/simplest.feature +11 -0
  54. data/features/snippet.feature +23 -0
  55. data/features/snippets_when_using_star_keyword.feature +36 -0
  56. data/features/step_definitions/cucumber_steps.rb +153 -7
  57. data/features/step_definitions/extra_steps.rb +2 -0
  58. data/features/step_definitions/simplest_steps.rb +3 -0
  59. data/features/step_definitions/wire_steps.rb +32 -0
  60. data/features/support/env.rb +140 -18
  61. data/features/support/env.rb.simplest +7 -0
  62. data/features/support/fake_wire_server.rb +77 -0
  63. data/features/table_diffing.feature +45 -0
  64. data/features/table_mapping.feature +34 -0
  65. data/features/tag_logic.feature +258 -0
  66. data/features/transform.feature +245 -0
  67. data/features/unicode_table.feature +35 -0
  68. data/features/usage_and_stepdefs_formatter.feature +169 -0
  69. data/features/wire_protocol.feature +332 -0
  70. data/features/wire_protocol_table_diffing.feature +119 -0
  71. data/features/wire_protocol_tags.feature +87 -0
  72. data/features/wire_protocol_timeouts.feature +63 -0
  73. data/features/work_in_progress.feature +156 -0
  74. data/fixtures/json/features/pystring.feature +8 -0
  75. data/fixtures/junit/features/pending.feature +1 -3
  76. data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +12 -0
  77. data/fixtures/self_test/features/background/background_with_name.feature +7 -0
  78. data/fixtures/self_test/features/background/failing_background.feature +12 -0
  79. data/fixtures/self_test/features/background/failing_background_after_success.feature +11 -0
  80. data/fixtures/self_test/features/background/multiline_args_background.feature +32 -0
  81. data/fixtures/self_test/features/background/passing_background.feature +10 -0
  82. data/fixtures/self_test/features/background/pending_background.feature +10 -0
  83. data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +16 -0
  84. data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +16 -0
  85. data/fixtures/self_test/features/support/env.rb +0 -8
  86. data/fixtures/tickets/features.html +1 -1
  87. data/gem_tasks/examples.rake +1 -1
  88. data/gem_tasks/features.rake +14 -0
  89. data/gem_tasks/sdoc.rake +12 -0
  90. data/lib/cucumber.rb +0 -12
  91. data/lib/cucumber/ast.rb +1 -1
  92. data/lib/cucumber/ast/background.rb +5 -21
  93. data/lib/cucumber/ast/examples.rb +4 -12
  94. data/lib/cucumber/ast/feature.rb +5 -13
  95. data/lib/cucumber/ast/feature_element.rb +4 -9
  96. data/lib/cucumber/ast/outline_table.rb +4 -4
  97. data/lib/cucumber/ast/py_string.rb +80 -0
  98. data/lib/cucumber/ast/scenario.rb +5 -7
  99. data/lib/cucumber/ast/scenario_outline.rb +15 -23
  100. data/lib/cucumber/ast/step.rb +0 -5
  101. data/lib/cucumber/ast/step_invocation.rb +15 -21
  102. data/lib/cucumber/ast/table.rb +8 -14
  103. data/lib/cucumber/ast/tree_walker.rb +48 -10
  104. data/lib/cucumber/cli/configuration.rb +8 -33
  105. data/lib/cucumber/cli/main.rb +35 -20
  106. data/lib/cucumber/cli/options.rb +7 -8
  107. data/lib/cucumber/cli/profile_loader.rb +0 -2
  108. data/lib/cucumber/core_ext/proc.rb +1 -2
  109. data/lib/cucumber/feature_file.rb +15 -47
  110. data/lib/cucumber/formatter/ansicolor.rb +5 -3
  111. data/lib/cucumber/formatter/color_io.rb +23 -0
  112. data/lib/cucumber/formatter/console.rb +23 -27
  113. data/lib/cucumber/formatter/cucumber.css +17 -34
  114. data/lib/cucumber/formatter/cucumber.sass +182 -173
  115. data/lib/cucumber/formatter/html.rb +11 -46
  116. data/lib/cucumber/formatter/io.rb +4 -2
  117. data/lib/cucumber/formatter/json.rb +152 -15
  118. data/lib/cucumber/formatter/json_pretty.rb +6 -5
  119. data/lib/cucumber/formatter/junit.rb +22 -28
  120. data/lib/cucumber/formatter/pdf.rb +6 -6
  121. data/lib/cucumber/formatter/pretty.rb +5 -5
  122. data/lib/cucumber/formatter/rerun.rb +11 -22
  123. data/lib/cucumber/formatter/tag_cloud.rb +35 -0
  124. data/lib/cucumber/formatter/unicode.rb +20 -41
  125. data/lib/cucumber/js_support/js_dsl.js +4 -4
  126. data/lib/cucumber/js_support/js_language.rb +5 -9
  127. data/lib/cucumber/js_support/js_snippets.rb +2 -2
  128. data/lib/cucumber/language_support.rb +2 -2
  129. data/lib/cucumber/parser/gherkin_builder.rb +30 -35
  130. data/lib/cucumber/platform.rb +8 -8
  131. data/lib/cucumber/py_support/py_language.rb +2 -2
  132. data/lib/cucumber/rake/task.rb +31 -74
  133. data/lib/cucumber/rb_support/rb_dsl.rb +0 -1
  134. data/lib/cucumber/rb_support/rb_language.rb +8 -10
  135. data/lib/cucumber/rb_support/rb_step_definition.rb +0 -8
  136. data/lib/cucumber/rb_support/rb_transform.rb +0 -17
  137. data/lib/cucumber/rb_support/rb_world.rb +18 -26
  138. data/lib/cucumber/rspec/doubles.rb +3 -3
  139. data/lib/cucumber/step_match.rb +2 -6
  140. data/lib/cucumber/step_mother.rb +427 -6
  141. data/lib/cucumber/wire_support/configuration.rb +1 -4
  142. data/lib/cucumber/wire_support/wire_language.rb +10 -3
  143. data/spec/cucumber/ast/background_spec.rb +6 -68
  144. data/spec/cucumber/ast/feature_factory.rb +4 -5
  145. data/spec/cucumber/ast/feature_spec.rb +4 -4
  146. data/spec/cucumber/ast/outline_table_spec.rb +1 -1
  147. data/spec/cucumber/ast/py_string_spec.rb +40 -0
  148. data/spec/cucumber/ast/scenario_outline_spec.rb +11 -15
  149. data/spec/cucumber/ast/scenario_spec.rb +4 -4
  150. data/spec/cucumber/ast/step_spec.rb +3 -3
  151. data/spec/cucumber/ast/table_spec.rb +2 -38
  152. data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
  153. data/spec/cucumber/broadcaster_spec.rb +1 -1
  154. data/spec/cucumber/cli/configuration_spec.rb +6 -32
  155. data/spec/cucumber/cli/drb_client_spec.rb +3 -2
  156. data/spec/cucumber/cli/main_spec.rb +43 -43
  157. data/spec/cucumber/cli/options_spec.rb +1 -28
  158. data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
  159. data/spec/cucumber/core_ext/proc_spec.rb +1 -1
  160. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  161. data/spec/cucumber/formatter/color_io_spec.rb +29 -0
  162. data/spec/cucumber/formatter/duration_spec.rb +1 -1
  163. data/spec/cucumber/formatter/html_spec.rb +5 -3
  164. data/spec/cucumber/formatter/junit_spec.rb +2 -16
  165. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  166. data/spec/cucumber/formatter/spec_helper.rb +12 -11
  167. data/spec/cucumber/rb_support/rb_language_spec.rb +28 -241
  168. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +28 -33
  169. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
  170. data/spec/cucumber/step_match_spec.rb +9 -11
  171. data/spec/cucumber/step_mother_spec.rb +302 -0
  172. data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
  173. data/spec/cucumber/wire_support/connection_spec.rb +1 -1
  174. data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
  175. data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
  176. data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
  177. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  178. data/spec/cucumber/world/pending_spec.rb +2 -2
  179. data/spec/spec_helper.rb +20 -13
  180. metadata +78 -4
@@ -0,0 +1,332 @@
1
+ @wire
2
+ Feature: Wire Protocol
3
+ In order to be allow Cucumber to touch my app in intimate places
4
+ As a developer on platform which doesn't support Ruby
5
+ I want a low-level protocol which Cucumber can use to run steps within my app
6
+
7
+ #
8
+ # Cucumber's wire protocol is an implementation of Cucumber's internal
9
+ # 'programming language' abstraction, and allows step definitions to be
10
+ # implemented and invoked on any platform.
11
+ #
12
+ # Communication is over a TCP socket, which Cucumber connects to when it finds
13
+ # a definition file with the .wire extension in the step_definitions folder
14
+ # (or other load path).
15
+ #
16
+ # Cucumber sends the following request messages out over the wire:
17
+ #
18
+ # * step_matches : this is used to find out whether the wire server has a
19
+ # definition for a given step
20
+ # * invoke : this is used to ask for a step definition to be invoked
21
+ # * begin_scenario : signals that cucumber is about to execute a scenario
22
+ # * end_scenario : signals that cucumber has finished executing a scenario
23
+ # * snippet_text : requests a snippet for an undefined step
24
+ #
25
+ # Every message supports two standard responses:
26
+ # * success : which expects different arguments (sometimes none at
27
+ # all) depending on the request.
28
+ # * fail : causes a Cucumber::WireSupport::WireException to be
29
+ # raised.
30
+ #
31
+ # Some messages support more responses - see below for details.
32
+ #
33
+ # A WirePacket flowing in either direction is formatted as a JSON-encoded
34
+ # string, with a newline character signalling the end of a packet. See the
35
+ # specs for Cucumber::WireSupport::WirePacket for more details.
36
+ #
37
+ # These messages are described in detail below, with examples.
38
+ #
39
+
40
+ Background:
41
+ Given a standard Cucumber project directory structure
42
+ And a file named "features/wired.feature" with:
43
+ """
44
+ Feature: High strung
45
+ Scenario: Wired
46
+ Given we're all wired
47
+
48
+ """
49
+ And a file named "features/step_definitions/some_remote_place.wire" with:
50
+ """
51
+ host: localhost
52
+ port: 54321
53
+
54
+ """
55
+
56
+
57
+ #
58
+ # # Request: 'step_matches'
59
+ #
60
+ # When the features have been parsed, Cucumber will send a step_matches
61
+ # message to ask the wire server if it can match a step name. This happens for
62
+ # each of the steps in each of the features.
63
+ #
64
+ # The wire server replies with an array of StepMatch objects.
65
+
66
+ Scenario: Dry run finds no step match
67
+ Given there is a wire server running on port 54321 which understands the following protocol:
68
+ | request | response |
69
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
70
+ When I run cucumber --dry-run -f progress
71
+ And it should pass with
72
+ """
73
+ U
74
+
75
+ 1 scenario (1 undefined)
76
+ 1 step (1 undefined)
77
+
78
+ """
79
+
80
+ # When each StepMatch is returned, it contains the following data:
81
+ # * id - identifier for the step definition to be used later when if it
82
+ # needs to be invoked. The identifier can be any string value and
83
+ # is simply used for the wire server's own reference.
84
+ # * args - any argument values as captured by the wire end's own regular
85
+ # expression (or other argument matching) process.
86
+ Scenario: Dry run finds a step match
87
+ Given there is a wire server running on port 54321 which understands the following protocol:
88
+ | request | response |
89
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
90
+ When I run cucumber --dry-run -f progress
91
+ And it should pass with
92
+ """
93
+ -
94
+
95
+ 1 scenario (1 skipped)
96
+ 1 step (1 skipped)
97
+
98
+ """
99
+
100
+ # Optionally, the StepMatch can also contain a source reference, and a native
101
+ # regexp string which will be used by some formatters.
102
+ Scenario: Step matches returns details about the remote step definition
103
+ Given there is a wire server running on port 54321 which understands the following protocol:
104
+ | request | response |
105
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[], "source":"MyApp.MyClass:123", "regexp":"we.*"}]] |
106
+ When I run cucumber -f stepdefs --dry-run
107
+ Then STDERR should be empty
108
+ And it should pass with
109
+ """
110
+ -
111
+
112
+ we.* # MyApp.MyClass:123
113
+
114
+ 1 scenario (1 skipped)
115
+ 1 step (1 skipped)
116
+
117
+ """
118
+
119
+
120
+ #
121
+ # # Request: 'invoke'
122
+ #
123
+ # Assuming a StepMatch was returned for a given step name, when it's time to
124
+ # invoke that step definition, Cucumber will send an invoke message.
125
+ #
126
+ # The invoke message contains the ID of the step definition, as returned by
127
+ # the wire server in response to the the step_matches call, along with the
128
+ # arguments that were parsed from the step name during the same step_matches
129
+ # call.
130
+ #
131
+ # The wire server will normally[1] reply one of the following:
132
+ # * success
133
+ # * fail
134
+ # * pending : optionally takes a message argument
135
+ #
136
+ # [1] This isn't the whole story: see also wire_protocol_table_diffing.feature
137
+ #
138
+
139
+ # ## Pending Steps
140
+ #
141
+ Scenario: Invoke a step definition which is pending
142
+ Given there is a wire server running on port 54321 which understands the following protocol:
143
+ | request | response |
144
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
145
+ | ["begin_scenario"] | ["success"] |
146
+ | ["invoke",{"id":"1","args":[]}] | ["pending", "I'll do it later"] |
147
+ | ["end_scenario"] | ["success"] |
148
+ When I run cucumber -f pretty -q
149
+ And it should pass with
150
+ """
151
+ Feature: High strung
152
+
153
+ Scenario: Wired
154
+ Given we're all wired
155
+ I'll do it later (Cucumber::Pending)
156
+ features/wired.feature:3:in `Given we're all wired'
157
+
158
+ 1 scenario (1 pending)
159
+ 1 step (1 pending)
160
+
161
+ """
162
+
163
+ # ## Passing Steps
164
+ #
165
+ Scenario: Invoke a step definition which passes
166
+ Given there is a wire server running on port 54321 which understands the following protocol:
167
+ | request | response |
168
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
169
+ | ["begin_scenario"] | ["success"] |
170
+ | ["invoke",{"id":"1","args":[]}] | ["success"] |
171
+ | ["end_scenario"] | ["success"] |
172
+ When I run cucumber -f progress
173
+ And it should pass with
174
+ """
175
+ .
176
+
177
+ 1 scenario (1 passed)
178
+ 1 step (1 passed)
179
+
180
+ """
181
+
182
+ # ## Failing Steps
183
+ #
184
+ # When an invoked step definition fails, it can return details of the exception
185
+ # in the reply to invoke. This causes a Cucumber::WireSupport::WireException to be
186
+ # raised.
187
+ #
188
+ # Valid arguments are:
189
+ # * message (mandatory)
190
+ # * exception
191
+ # * backtrace
192
+ #
193
+ # See the specs for Cucumber::WireSupport::WireException for more details
194
+ #
195
+ Scenario: Invoke a step definition which fails
196
+ Given there is a wire server running on port 54321 which understands the following protocol:
197
+ | request | response |
198
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
199
+ | ["begin_scenario"] | ["success"] |
200
+ | ["invoke",{"id":"1","args":[]}] | ["fail",{"message":"The wires are down", "exception":"Some.Foreign.ExceptionType"}] |
201
+ | ["end_scenario"] | ["success"] |
202
+ When I run cucumber -f progress
203
+ Then STDERR should be empty
204
+ And it should fail with
205
+ """
206
+ F
207
+
208
+ (::) failed steps (::)
209
+
210
+ The wires are down (Some.Foreign.ExceptionType from localhost:54321)
211
+ features/wired.feature:3:in `Given we're all wired'
212
+
213
+ Failing Scenarios:
214
+ cucumber features/wired.feature:2 # Scenario: Wired
215
+
216
+ 1 scenario (1 failed)
217
+ 1 step (1 failed)
218
+
219
+ """
220
+
221
+ # ## Step Arguments
222
+ #
223
+ # Imagine we have a step definition like:
224
+ #
225
+ # Given /we're all (.*)/ do | what_we_are |
226
+ # end
227
+ #
228
+ # When this step definition matches the step name in our feature, the word
229
+ # 'wired' will be captured as an argument.
230
+ #
231
+ # Cucumber expects this StepArgument to be returned in the StepMatch. The keys
232
+ # have the following meanings:
233
+ # * val : the value of the string captured for that argument from the step
234
+ # name passed in step_matches
235
+ # * pos : the position within the step name that the argument was matched
236
+ # (used for formatter highlighting)
237
+ #
238
+ Scenario: Invoke a step definition which takes string arguments (and passes)
239
+ Given there is a wire server running on port 54321 which understands the following protocol:
240
+ | request | response |
241
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[{"val":"wired", "pos":10}]}]] |
242
+ | ["begin_scenario"] | ["success"] |
243
+ | ["invoke",{"id":"1","args":["wired"]}] | ["success"] |
244
+ | ["end_scenario"] | ["success"] |
245
+ When I run cucumber -f progress
246
+ Then STDERR should be empty
247
+ And it should pass with
248
+ """
249
+ .
250
+
251
+ 1 scenario (1 passed)
252
+ 1 step (1 passed)
253
+
254
+ """
255
+
256
+ # ## Multiline Table Arguments
257
+ #
258
+ # When the step has a multiline table argument, it will be passed with the
259
+ # invoke message as a string - a serialized JSON array of array of strings.
260
+ # In the following scenario our step definition takes two arguments - one
261
+ # captures the "we're" and the other takes the table.
262
+ Scenario: Invoke a step definition which takes table arguments (and passes)
263
+ Given a file named "features/wired_on_tables.feature" with:
264
+ """
265
+ Feature: High strung
266
+ Scenario: Wired and more
267
+ Given we're all:
268
+ | wired |
269
+ | high |
270
+ | happy |
271
+ """
272
+ And there is a wire server running on port 54321 which understands the following protocol:
273
+ | request | response |
274
+ | ["step_matches",{"name_to_match":"we're all:"}] | ["success",[{"id":"1", "args":[{"val":"we're", "pos":0}]}]] |
275
+ | ["begin_scenario"] | ["success"] |
276
+ | ["invoke",{"id":"1","args":["we're",[["wired"],["high"],["happy"]]]}] | ["success"] |
277
+ | ["end_scenario"] | ["success"] |
278
+ When I run cucumber -f progress features/wired_on_tables.feature
279
+ Then STDERR should be empty
280
+ And it should pass with
281
+ """
282
+ .
283
+
284
+ 1 scenario (1 passed)
285
+ 1 step (1 passed)
286
+
287
+ """
288
+
289
+
290
+ #
291
+ # # Request: 'snippets'
292
+ #
293
+ Scenario: Wire server returns snippets for a step that didn't match
294
+ Given there is a wire server running on port 54321 which understands the following protocol:
295
+ | request | response |
296
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
297
+ | ["snippet_text",{"step_keyword":"Given ","multiline_arg_class":"","step_name":"we're all wired"}] | ["success","foo()\n bar;\nbaz"] |
298
+ | ["begin_scenario"] | ["success"] |
299
+ | ["end_scenario"] | ["success"] |
300
+ When I run cucumber -f pretty
301
+ Then STDERR should be empty
302
+ And it should pass with
303
+ """
304
+ Feature: High strung
305
+
306
+ Scenario: Wired # features/wired.feature:2
307
+ Given we're all wired # features/wired.feature:3
308
+
309
+ 1 scenario (1 undefined)
310
+ 1 step (1 undefined)
311
+
312
+ You can implement step definitions for undefined steps with these snippets:
313
+
314
+ foo()
315
+ bar;
316
+ baz
317
+
318
+
319
+ """
320
+
321
+ #
322
+ # # Bad Response
323
+ #
324
+ Scenario: Unexpected response
325
+ Given there is a wire server running on port 54321 which understands the following protocol:
326
+ | request | response |
327
+ | ["begin_scenario"] | ["yikes"] |
328
+ When I run cucumber -f progress
329
+ Then STDERR should match
330
+ """
331
+ undefined method `handle_yikes'
332
+ """
@@ -0,0 +1,119 @@
1
+ @wire
2
+ Feature: Wire protocol table diffing
3
+ In order to use the amazing functionality in the Cucumber table object
4
+ As a wire server
5
+ I want to be able to ask for a table diff during a step definition invocation
6
+
7
+ Background:
8
+ Given a standard Cucumber project directory structure
9
+ And a file named "features/wired.feature" with:
10
+ """
11
+ Feature: Hello
12
+ Scenario: Wired
13
+ Given we're all wired
14
+
15
+ """
16
+ And a file named "features/step_definitions/some_remote_place.wire" with:
17
+ """
18
+ host: localhost
19
+ port: 54321
20
+
21
+ """
22
+
23
+ Scenario: Invoke a step definition tries to diff the table and fails
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",[{"id":"1", "args":[]}]] |
27
+ | ["begin_scenario"] | ["success"] |
28
+ | ["invoke",{"id":"1","args":[]}] | ["diff",[[["a","b"],["c","d"]],[["x","y"],["z","z"]]]] |
29
+ | ["diff_failed"] | ["fail",{"message":"Not same", "exception":"DifferentException", "backtrace":["a.cs:12","b.cs:34"]}] |
30
+ | ["end_scenario"] | ["success"] |
31
+ When I run cucumber -f progress --backtrace
32
+ Then STDERR should be empty
33
+ And it should fail with
34
+ """
35
+ F
36
+
37
+ (::) failed steps (::)
38
+
39
+ Not same (DifferentException from localhost:54321)
40
+ a.cs:12
41
+ b.cs:34
42
+ features/wired.feature:3:in `Given we're all wired'
43
+
44
+ Failing Scenarios:
45
+ cucumber features/wired.feature:2 # Scenario: Wired
46
+
47
+ 1 scenario (1 failed)
48
+ 1 step (1 failed)
49
+
50
+ """
51
+
52
+ Scenario: Invoke a step definition tries to diff the table and passes
53
+ Given there is a wire server running on port 54321 which understands the following protocol:
54
+ | request | response |
55
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
56
+ | ["begin_scenario"] | ["success"] |
57
+ | ["invoke",{"id":"1","args":[]}] | ["diff",[[["a"],["b"]],[["a"],["b"]]]] |
58
+ | ["diff_ok"] | ["success"] |
59
+ | ["end_scenario"] | ["success"] |
60
+ When I run cucumber -f progress
61
+ And it should pass with
62
+ """
63
+ .
64
+
65
+ 1 scenario (1 passed)
66
+ 1 step (1 passed)
67
+
68
+ """
69
+
70
+ Scenario: Invoke a step definition which successfully diffs a table but then fails
71
+ Given there is a wire server running on port 54321 which understands the following protocol:
72
+ | request | response |
73
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
74
+ | ["begin_scenario"] | ["success"] |
75
+ | ["invoke",{"id":"1","args":[]}] | ["diff",[[["a"],["b"]],[["a"],["b"]]]] |
76
+ | ["diff_ok"] | ["fail",{"message":"I wanted things to be different for us"}] |
77
+ | ["end_scenario"] | ["success"] |
78
+ When I run cucumber -f progress
79
+ And it should fail with
80
+ """
81
+ F
82
+
83
+ (::) failed steps (::)
84
+
85
+ I wanted things to be different for us (Cucumber::WireSupport::WireException)
86
+ features/wired.feature:3:in `Given we're all wired'
87
+
88
+ Failing Scenarios:
89
+ cucumber features/wired.feature:2 # Scenario: Wired
90
+
91
+ 1 scenario (1 failed)
92
+ 1 step (1 failed)
93
+
94
+ """
95
+
96
+ Scenario: Invoke a step definition which asks for an immediate diff that fails
97
+ Given there is a wire server running on port 54321 which understands the following protocol:
98
+ | request | response |
99
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
100
+ | ["begin_scenario"] | ["success"] |
101
+ | ["invoke",{"id":"1","args":[]}] | ["diff!",[[["a"]],[["b"]]]] |
102
+ | ["end_scenario"] | ["success"] |
103
+ When I run cucumber -f progress
104
+ And it should fail with
105
+ """
106
+ F
107
+
108
+ (::) failed steps (::)
109
+
110
+ Tables were not identical (Cucumber::Ast::Table::Different)
111
+ features/wired.feature:3:in `Given we're all wired'
112
+
113
+ Failing Scenarios:
114
+ cucumber features/wired.feature:2 # Scenario: Wired
115
+
116
+ 1 scenario (1 failed)
117
+ 1 step (1 failed)
118
+
119
+ """