cucumber 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/.travis.yml +3 -2
- data/DEVELOPERS.md +48 -0
- data/History.md +22 -3
- data/README.md +13 -31
- data/Rakefile +1 -0
- data/cucumber.gemspec +18 -17
- data/cucumber.yml +3 -2
- data/examples/i18n/cs/Rakefile +6 -0
- data/examples/i18n/cs/features/addition.feature +17 -0
- data/examples/i18n/cs/features/division.feature +11 -0
- data/examples/i18n/cs/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/cs/lib/calculator.rb +14 -0
- data/examples/i18n/hi/Rakefile +6 -0
- data/examples/i18n/hi/features/addition.feature +16 -0
- data/examples/i18n/hi/features/division.feature +10 -0
- data/examples/i18n/hi/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/hi/lib/calculator.rb +15 -0
- data/examples/python/README.textile +2 -1
- data/examples/ruby2python/README.textile +2 -1
- data/features/.cucumber/stepdefs.json +1688 -445
- data/features/assertions.feature +69 -0
- data/features/formatter_callbacks.feature +189 -0
- data/features/html_formatter.feature +19 -0
- data/features/json_formatter.feature +8 -4
- data/features/nested_steps_with_second_arg.feature +73 -0
- data/features/step_definitions.feature +65 -0
- data/features/step_definitions/cucumber_steps.rb +18 -3
- data/fixtures/self_test/features/support/env.rb +1 -1
- data/gem_tasks/cucumber.rake +5 -3
- data/gem_tasks/downloads.rb +3 -3
- data/gem_tasks/stats +4 -2
- data/gem_tasks/yard.rake +31 -13
- data/legacy_features/default_snippets.feature +3 -3
- data/legacy_features/language_help.feature +4 -0
- data/legacy_features/report_called_undefined_steps.feature +1 -1
- data/legacy_features/snippet.feature +3 -3
- data/legacy_features/snippets_when_using_star_keyword.feature +1 -1
- data/legacy_features/step_definitions/cucumber_steps.rb +4 -3
- data/legacy_features/support/env.rb +1 -1
- data/legacy_features/support/fake_wire_server.rb +9 -9
- data/lib/autotest/cucumber_mixin.rb +14 -14
- data/lib/autotest/discover.rb +2 -0
- data/lib/cucumber.rb +2 -2
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +11 -7
- data/lib/cucumber/ast/comment.rb +2 -2
- data/lib/cucumber/ast/doc_string.rb +1 -1
- data/lib/cucumber/ast/examples.rb +1 -1
- data/lib/cucumber/ast/feature.rb +2 -2
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/multiline_argument.rb +2 -2
- data/lib/cucumber/ast/names.rb +2 -2
- data/lib/cucumber/ast/outline_table.rb +4 -5
- data/lib/cucumber/ast/scenario.rb +14 -14
- data/lib/cucumber/ast/scenario_outline.rb +4 -4
- data/lib/cucumber/ast/step.rb +3 -3
- data/lib/cucumber/ast/step_collection.rb +5 -5
- data/lib/cucumber/ast/step_invocation.rb +8 -8
- data/lib/cucumber/ast/table.rb +40 -27
- data/lib/cucumber/ast/tree_walker.rb +9 -8
- data/lib/cucumber/ast/visitor.rb +1 -1
- data/lib/cucumber/cli/configuration.rb +10 -10
- data/lib/cucumber/cli/drb_client.rb +1 -1
- data/lib/cucumber/cli/main.rb +3 -3
- data/lib/cucumber/cli/options.rb +3 -2
- data/lib/cucumber/cli/profile_loader.rb +1 -1
- data/lib/cucumber/configuration.rb +12 -12
- data/lib/cucumber/constantize.rb +11 -2
- data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +1 -1
- data/lib/cucumber/core_ext/instance_exec.rb +4 -4
- data/lib/cucumber/core_ext/proc.rb +3 -3
- data/lib/cucumber/errors.rb +1 -1
- data/lib/cucumber/feature_file.rb +1 -1
- data/lib/cucumber/formatter/ansicolor.rb +36 -23
- data/lib/cucumber/formatter/console.rb +45 -25
- data/lib/cucumber/formatter/debug.rb +7 -7
- data/lib/cucumber/formatter/duration.rb +1 -1
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +7 -0
- data/lib/cucumber/formatter/gpretty.rb +1 -1
- data/lib/cucumber/formatter/html.rb +52 -53
- data/lib/cucumber/formatter/interceptor.rb +2 -2
- data/lib/cucumber/formatter/json.rb +1 -1
- data/lib/cucumber/formatter/json_pretty.rb +2 -1
- data/lib/cucumber/formatter/junit.rb +1 -1
- data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +12 -12
- data/lib/cucumber/formatter/progress.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +5 -5
- data/lib/cucumber/formatter/stepdefs.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +6 -6
- data/lib/cucumber/formatter/summary.rb +6 -6
- data/lib/cucumber/formatter/unicode.rb +18 -18
- data/lib/cucumber/formatter/usage.rb +7 -7
- data/lib/cucumber/js_support/js_dsl.js +1 -1
- data/lib/cucumber/language_support.rb +1 -1
- data/lib/cucumber/parser/gherkin_builder.rb +33 -33
- data/lib/cucumber/platform.rb +3 -2
- data/lib/cucumber/py_support/py_dsl.py +2 -2
- data/lib/cucumber/py_support/py_language.py +2 -2
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +4 -3
- data/lib/cucumber/rb_support/rb_dsl.rb +10 -10
- data/lib/cucumber/rb_support/rb_language.rb +27 -19
- data/lib/cucumber/rb_support/rb_step_definition.rb +39 -11
- data/lib/cucumber/rb_support/rb_transform.rb +3 -3
- data/lib/cucumber/rb_support/rb_world.rb +15 -15
- data/lib/cucumber/rb_support/regexp_argument_matcher.rb +1 -1
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
- data/lib/cucumber/rspec/doubles.rb +1 -1
- data/lib/cucumber/runtime.rb +11 -10
- data/lib/cucumber/runtime/features_loader.rb +6 -6
- data/lib/cucumber/runtime/for_programming_languages.rb +8 -15
- data/lib/cucumber/runtime/results.rb +6 -6
- data/lib/cucumber/runtime/support_code.rb +37 -28
- data/lib/cucumber/runtime/user_interface.rb +4 -4
- data/lib/cucumber/step_definition_light.rb +4 -4
- data/lib/cucumber/step_definitions.rb +2 -3
- data/lib/cucumber/step_match.rb +6 -6
- data/lib/cucumber/step_mother.rb +1 -1
- data/lib/cucumber/term/ansicolor.rb +22 -22
- data/lib/cucumber/wire_support/configuration.rb +11 -14
- data/lib/cucumber/wire_support/connection.rb +10 -9
- data/lib/cucumber/wire_support/request_handler.rb +3 -3
- data/lib/cucumber/wire_support/wire_exception.rb +3 -3
- data/lib/cucumber/wire_support/wire_language.rb +11 -11
- data/lib/cucumber/wire_support/wire_packet.rb +7 -5
- data/lib/cucumber/wire_support/wire_protocol.rb +6 -6
- data/lib/cucumber/wire_support/wire_protocol/requests.rb +20 -20
- data/lib/cucumber/wire_support/wire_step_definition.rb +4 -4
- data/spec/cucumber/ast/background_spec.rb +4 -4
- data/spec/cucumber/ast/doc_string_spec.rb +8 -8
- data/spec/cucumber/ast/feature_factory.rb +4 -4
- data/spec/cucumber/ast/feature_spec.rb +18 -18
- data/spec/cucumber/ast/outline_table_spec.rb +3 -3
- data/spec/cucumber/ast/step_spec.rb +4 -4
- data/spec/cucumber/ast/table_spec.rb +50 -29
- data/spec/cucumber/ast/tree_walker_spec.rb +12 -4
- data/spec/cucumber/broadcaster_spec.rb +1 -1
- data/spec/cucumber/cli/configuration_spec.rb +10 -4
- data/spec/cucumber/cli/drb_client_spec.rb +1 -1
- data/spec/cucumber/cli/main_spec.rb +28 -7
- data/spec/cucumber/cli/options_spec.rb +3 -3
- data/spec/cucumber/configuration_spec.rb +4 -4
- data/spec/cucumber/constantize_spec.rb +2 -0
- data/spec/cucumber/core_ext/proc_spec.rb +7 -7
- data/spec/cucumber/formatter/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/duration_spec.rb +2 -2
- data/spec/cucumber/formatter/html_spec.rb +31 -31
- data/spec/cucumber/formatter/interceptor_spec.rb +10 -0
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +7 -7
- data/spec/cucumber/rake/forked_spec.rb +15 -2
- data/spec/cucumber/rake/rcov_spec.rb +2 -2
- data/spec/cucumber/rb_support/rb_language_spec.rb +34 -17
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +45 -35
- data/spec/cucumber/rb_support/rb_transform_spec.rb +3 -3
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +31 -0
- data/spec/cucumber/runtime/results_spec.rb +5 -5
- data/spec/cucumber/runtime/support_code_spec.rb +13 -2
- data/spec/cucumber/runtime_spec.rb +7 -7
- data/spec/cucumber/step_match_spec.rb +2 -2
- data/spec/cucumber/wire_support/configuration_spec.rb +16 -6
- data/spec/cucumber/wire_support/connection_spec.rb +25 -11
- data/spec/cucumber/wire_support/wire_exception_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_language_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_packet_spec.rb +4 -4
- data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +98 -128
- data/legacy_features/html_formatter.feature +0 -8
- data/legacy_features/html_formatter/a.html +0 -561
@@ -0,0 +1,69 @@
|
|
1
|
+
Feature: Assertions
|
2
|
+
In order to get started quickly
|
3
|
+
As a new Cucumber user
|
4
|
+
I want to use a familiar assertion library
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "features/assert.feature" with:
|
8
|
+
"""
|
9
|
+
Feature: Assert
|
10
|
+
Scenario: Passing
|
11
|
+
Then it should pass
|
12
|
+
"""
|
13
|
+
|
14
|
+
Given a file named "without_rspec.rb" with:
|
15
|
+
"""
|
16
|
+
require 'rubygems' if RUBY_VERSION <= '1.8.7'
|
17
|
+
require 'rspec/expectations'
|
18
|
+
|
19
|
+
module RSpec
|
20
|
+
remove_const :Matchers rescue nil
|
21
|
+
remove_const :Expectations rescue nil
|
22
|
+
end
|
23
|
+
|
24
|
+
module Spec
|
25
|
+
remove_const :Expectations rescue nil
|
26
|
+
end
|
27
|
+
"""
|
28
|
+
|
29
|
+
Scenario: Test::Unit
|
30
|
+
Given a file named "features/step_definitions/assert_steps.rb" with:
|
31
|
+
"""
|
32
|
+
Then /^it should pass$/ do
|
33
|
+
assert(2 + 2 == 4)
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
When I run `ruby -r./without_rspec -S cucumber`
|
37
|
+
Then it should pass with exactly:
|
38
|
+
"""
|
39
|
+
Feature: Assert
|
40
|
+
|
41
|
+
Scenario: Passing # features/assert.feature:2
|
42
|
+
Then it should pass # features/step_definitions/assert_steps.rb:1
|
43
|
+
|
44
|
+
1 scenario (1 passed)
|
45
|
+
1 step (1 passed)
|
46
|
+
0m0.012s
|
47
|
+
|
48
|
+
"""
|
49
|
+
|
50
|
+
Scenario: RSpec
|
51
|
+
Given a file named "features/step_definitions/assert_steps.rb" with:
|
52
|
+
"""
|
53
|
+
Then /^it should pass$/ do
|
54
|
+
(2 + 2).should == 4
|
55
|
+
end
|
56
|
+
"""
|
57
|
+
When I run `cucumber`
|
58
|
+
Then it should pass with exactly:
|
59
|
+
"""
|
60
|
+
Feature: Assert
|
61
|
+
|
62
|
+
Scenario: Passing # features/assert.feature:2
|
63
|
+
Then it should pass # features/step_definitions/assert_steps.rb:1
|
64
|
+
|
65
|
+
1 scenario (1 passed)
|
66
|
+
1 step (1 passed)
|
67
|
+
0m0.012s
|
68
|
+
|
69
|
+
"""
|
@@ -0,0 +1,189 @@
|
|
1
|
+
Feature: Formatter Callback
|
2
|
+
|
3
|
+
Scenario: callback if not expanded
|
4
|
+
Given a file named "features/f.feature" with:
|
5
|
+
"""
|
6
|
+
Feature: I'll use my own
|
7
|
+
because I'm worth it
|
8
|
+
Scenario: just print me
|
9
|
+
Given this step works
|
10
|
+
Scenario Outline: outline
|
11
|
+
Given <x> step works
|
12
|
+
Then <y>
|
13
|
+
Examples:
|
14
|
+
|x|y|
|
15
|
+
|this|that|
|
16
|
+
|here|there|
|
17
|
+
"""
|
18
|
+
And a file named "features/step_definitions/steps.rb" with:
|
19
|
+
"""
|
20
|
+
Given /^.+ step works$/ do
|
21
|
+
end
|
22
|
+
Then /^that|there$/ do
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
When I run cucumber "features/f.feature --format debug"
|
26
|
+
Then it should pass with exactly:
|
27
|
+
"""
|
28
|
+
before_features
|
29
|
+
before_feature
|
30
|
+
before_tags
|
31
|
+
after_tags
|
32
|
+
feature_name
|
33
|
+
before_feature_element
|
34
|
+
before_tags
|
35
|
+
after_tags
|
36
|
+
scenario_name
|
37
|
+
before_steps
|
38
|
+
before_step
|
39
|
+
before_step_result
|
40
|
+
step_name
|
41
|
+
after_step_result
|
42
|
+
after_step
|
43
|
+
after_steps
|
44
|
+
after_feature_element
|
45
|
+
before_feature_element
|
46
|
+
before_tags
|
47
|
+
after_tags
|
48
|
+
scenario_name
|
49
|
+
before_steps
|
50
|
+
before_step
|
51
|
+
before_step_result
|
52
|
+
step_name
|
53
|
+
after_step_result
|
54
|
+
after_step
|
55
|
+
before_step
|
56
|
+
before_step_result
|
57
|
+
step_name
|
58
|
+
after_step_result
|
59
|
+
after_step
|
60
|
+
after_steps
|
61
|
+
before_examples_array
|
62
|
+
before_examples
|
63
|
+
examples_name
|
64
|
+
before_outline_table
|
65
|
+
before_table_row
|
66
|
+
before_table_cell
|
67
|
+
table_cell_value
|
68
|
+
after_table_cell
|
69
|
+
before_table_cell
|
70
|
+
table_cell_value
|
71
|
+
after_table_cell
|
72
|
+
after_table_row
|
73
|
+
before_table_row
|
74
|
+
before_table_cell
|
75
|
+
table_cell_value
|
76
|
+
after_table_cell
|
77
|
+
before_table_cell
|
78
|
+
table_cell_value
|
79
|
+
after_table_cell
|
80
|
+
after_table_row
|
81
|
+
before_table_row
|
82
|
+
before_table_cell
|
83
|
+
table_cell_value
|
84
|
+
after_table_cell
|
85
|
+
before_table_cell
|
86
|
+
table_cell_value
|
87
|
+
after_table_cell
|
88
|
+
after_table_row
|
89
|
+
after_outline_table
|
90
|
+
after_examples
|
91
|
+
after_examples_array
|
92
|
+
after_feature_element
|
93
|
+
after_feature
|
94
|
+
after_features
|
95
|
+
|
96
|
+
"""
|
97
|
+
|
98
|
+
Scenario: callback if expanded
|
99
|
+
Given a file named "features/f.feature" with:
|
100
|
+
"""
|
101
|
+
Feature: I'll use my own
|
102
|
+
because I'm worth it
|
103
|
+
Scenario: just print me
|
104
|
+
Given this step works
|
105
|
+
Scenario Outline: outline
|
106
|
+
Given <x> step works
|
107
|
+
Then <y>
|
108
|
+
Examples:
|
109
|
+
|x|y|
|
110
|
+
|this|that|
|
111
|
+
|here|there|
|
112
|
+
"""
|
113
|
+
And a file named "features/step_definitions/steps.rb" with:
|
114
|
+
"""
|
115
|
+
Given /^.+ step works$/ do
|
116
|
+
end
|
117
|
+
Then /^that|there$/ do
|
118
|
+
end
|
119
|
+
"""
|
120
|
+
When I run cucumber "features/f.feature --format debug --expand"
|
121
|
+
Then it should pass with exactly:
|
122
|
+
"""
|
123
|
+
before_features
|
124
|
+
before_feature
|
125
|
+
before_tags
|
126
|
+
after_tags
|
127
|
+
feature_name
|
128
|
+
before_feature_element
|
129
|
+
before_tags
|
130
|
+
after_tags
|
131
|
+
scenario_name
|
132
|
+
before_steps
|
133
|
+
before_step
|
134
|
+
before_step_result
|
135
|
+
step_name
|
136
|
+
after_step_result
|
137
|
+
after_step
|
138
|
+
after_steps
|
139
|
+
after_feature_element
|
140
|
+
before_feature_element
|
141
|
+
before_tags
|
142
|
+
after_tags
|
143
|
+
scenario_name
|
144
|
+
before_steps
|
145
|
+
before_step
|
146
|
+
before_step_result
|
147
|
+
step_name
|
148
|
+
after_step_result
|
149
|
+
after_step
|
150
|
+
before_step
|
151
|
+
before_step_result
|
152
|
+
step_name
|
153
|
+
after_step_result
|
154
|
+
after_step
|
155
|
+
after_steps
|
156
|
+
before_examples_array
|
157
|
+
before_examples
|
158
|
+
examples_name
|
159
|
+
before_outline_table
|
160
|
+
scenario_name
|
161
|
+
before_step
|
162
|
+
before_step_result
|
163
|
+
step_name
|
164
|
+
after_step_result
|
165
|
+
after_step
|
166
|
+
before_step
|
167
|
+
before_step_result
|
168
|
+
step_name
|
169
|
+
after_step_result
|
170
|
+
after_step
|
171
|
+
scenario_name
|
172
|
+
before_step
|
173
|
+
before_step_result
|
174
|
+
step_name
|
175
|
+
after_step_result
|
176
|
+
after_step
|
177
|
+
before_step
|
178
|
+
before_step_result
|
179
|
+
step_name
|
180
|
+
after_step_result
|
181
|
+
after_step
|
182
|
+
after_outline_table
|
183
|
+
after_examples
|
184
|
+
after_examples_array
|
185
|
+
after_feature_element
|
186
|
+
after_feature
|
187
|
+
after_features
|
188
|
+
|
189
|
+
"""
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: HTML output formatter
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "features/scenario_outline_with_undefined_steps.feature" with:
|
5
|
+
"""
|
6
|
+
Feature:
|
7
|
+
|
8
|
+
Scenario Outline:
|
9
|
+
Given an undefined step
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
|foo|
|
13
|
+
|bar|
|
14
|
+
"""
|
15
|
+
|
16
|
+
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 "
|
18
|
+
Then it should pass
|
19
|
+
|
@@ -101,7 +101,8 @@ Feature: JSON output formatter
|
|
101
101
|
"location": "features/step_definitions/steps.rb:1"
|
102
102
|
},
|
103
103
|
"result": {
|
104
|
-
"status": "passed"
|
104
|
+
"status": "passed",
|
105
|
+
"duration": 1
|
105
106
|
}
|
106
107
|
}
|
107
108
|
]
|
@@ -129,7 +130,8 @@ Feature: JSON output formatter
|
|
129
130
|
},
|
130
131
|
"result": {
|
131
132
|
"status": "failed",
|
132
|
-
"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'"
|
133
|
+
"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'",
|
134
|
+
"duration": 1
|
133
135
|
}
|
134
136
|
}
|
135
137
|
]
|
@@ -191,7 +193,8 @@ Feature: JSON output formatter
|
|
191
193
|
},
|
192
194
|
"result": {
|
193
195
|
"status": "failed",
|
194
|
-
"error_message": "a string (RuntimeError)\n./features/step_definitions/doc_string_steps.rb:2:in `/I should fail with/'\nfeatures/doc_string.feature:4:in `Then I should fail with'"
|
196
|
+
"error_message": "a string (RuntimeError)\n./features/step_definitions/doc_string_steps.rb:2:in `/I should fail with/'\nfeatures/doc_string.feature:4:in `Then I should fail with'",
|
197
|
+
"duration": 1
|
195
198
|
}
|
196
199
|
}
|
197
200
|
]
|
@@ -236,7 +239,8 @@ Feature: JSON output formatter
|
|
236
239
|
"location": "features/step_definitions/steps.rb:29"
|
237
240
|
},
|
238
241
|
"result": {
|
239
|
-
"status": "passed"
|
242
|
+
"status": "passed",
|
243
|
+
"duration": 1
|
240
244
|
}
|
241
245
|
}
|
242
246
|
]
|
@@ -0,0 +1,73 @@
|
|
1
|
+
Feature: Nested Steps with either table or doc string
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a scenario with a step that looks like this:
|
5
|
+
"""gherkin
|
6
|
+
Given two turtles
|
7
|
+
"""
|
8
|
+
|
9
|
+
Scenario: Use #step with table
|
10
|
+
Given a step definition that looks like this:
|
11
|
+
"""ruby
|
12
|
+
Given /turtles:/ do |table|
|
13
|
+
table.hashes.each do |row|
|
14
|
+
puts row[:name]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
And a step definition that looks like this:
|
19
|
+
"""ruby
|
20
|
+
Given /two turtles/ do
|
21
|
+
step %{turtles:}, table(%{
|
22
|
+
| name |
|
23
|
+
| Sturm |
|
24
|
+
| Liouville |
|
25
|
+
})
|
26
|
+
end
|
27
|
+
"""
|
28
|
+
When I run the feature with the progress formatter
|
29
|
+
Then the output should contain:
|
30
|
+
"""
|
31
|
+
Sturm
|
32
|
+
|
33
|
+
Liouville
|
34
|
+
|
35
|
+
"""
|
36
|
+
|
37
|
+
Scenario: Use #step with docstring
|
38
|
+
Given a step definition that looks like this:
|
39
|
+
"""ruby
|
40
|
+
Given /two turtles/ do
|
41
|
+
step %{turtles:}, "Sturm and Lioville"
|
42
|
+
end
|
43
|
+
"""
|
44
|
+
And a step definition that looks like this:
|
45
|
+
"""ruby
|
46
|
+
Given /turtles:/ do |text|
|
47
|
+
puts text
|
48
|
+
end
|
49
|
+
"""
|
50
|
+
When I run the feature with the progress formatter
|
51
|
+
Then the output should contain:
|
52
|
+
"""
|
53
|
+
Sturm and Lioville
|
54
|
+
"""
|
55
|
+
|
56
|
+
Scenario: Use #step with docstring and content-type
|
57
|
+
Given a step definition that looks like this:
|
58
|
+
"""ruby
|
59
|
+
Given /two turtles/ do
|
60
|
+
step %{turtles:}, doc_string('Sturm and Lioville','math')
|
61
|
+
end
|
62
|
+
"""
|
63
|
+
And a step definition that looks like this:
|
64
|
+
"""ruby
|
65
|
+
Given /turtles:/ do |text|
|
66
|
+
puts text.content_type
|
67
|
+
end
|
68
|
+
"""
|
69
|
+
When I run the feature with the progress formatter
|
70
|
+
Then the output should contain:
|
71
|
+
"""
|
72
|
+
math
|
73
|
+
"""
|
@@ -0,0 +1,65 @@
|
|
1
|
+
Feature: Step Definitions
|
2
|
+
|
3
|
+
Everybody knows you can do step definitions in Cucumber
|
4
|
+
but did you know you can do this?
|
5
|
+
|
6
|
+
Scenario: Call a method in World directly from a step def
|
7
|
+
Given a file named "features/step_definitions/steps.rb" with:
|
8
|
+
"""
|
9
|
+
module Driver
|
10
|
+
def do_action
|
11
|
+
@done = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def assert_done
|
15
|
+
@done.should be_true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
World(Driver)
|
19
|
+
|
20
|
+
When /I do the action/, :do_action
|
21
|
+
Then /The action should be done/, :assert_done
|
22
|
+
"""
|
23
|
+
And a file named "features/action.feature" with:
|
24
|
+
"""
|
25
|
+
Feature:
|
26
|
+
Scenario:
|
27
|
+
When I do the action
|
28
|
+
Then the action should be done
|
29
|
+
"""
|
30
|
+
When I run `cucumber`
|
31
|
+
Then it should pass
|
32
|
+
|
33
|
+
Scenario: Call a method on an actor in the World directly from a step def
|
34
|
+
Given a file named "features/step_definitions/steps.rb" with:
|
35
|
+
"""
|
36
|
+
class Thing
|
37
|
+
def do_action
|
38
|
+
@done = true
|
39
|
+
end
|
40
|
+
|
41
|
+
def assert_done
|
42
|
+
@done.should be_true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Driver
|
47
|
+
def thing
|
48
|
+
@thing ||= Thing.new
|
49
|
+
end
|
50
|
+
end
|
51
|
+
World(Driver)
|
52
|
+
|
53
|
+
When /I do the action to the thing/, :do_action, :on => lambda { thing }
|
54
|
+
Then /The thing should be done/, :assert_done, :on => lambda { thing }
|
55
|
+
"""
|
56
|
+
And a file named "features/action.feature" with:
|
57
|
+
"""
|
58
|
+
Feature:
|
59
|
+
Scenario:
|
60
|
+
When I do the action to the thing
|
61
|
+
Then the thing should be done
|
62
|
+
"""
|
63
|
+
When I run `cucumber`
|
64
|
+
Then it should pass
|
65
|
+
|