cuke_modeler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.simplecov +8 -0
- data/Gemfile +4 -0
- data/History.rdoc +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +38 -0
- data/cuke_modeler.gemspec +29 -0
- data/features/analysis/test_comparison.feature +123 -0
- data/features/analysis/test_manipulation.feature +37 -0
- data/features/modeling/background_modeling.feature +75 -0
- data/features/modeling/background_output.feature +130 -0
- data/features/modeling/directory_modeling.feature +120 -0
- data/features/modeling/directory_output.feature +13 -0
- data/features/modeling/doc_string_modeling.feature +63 -0
- data/features/modeling/doc_string_output.feature +71 -0
- data/features/modeling/example_modeling.feature +111 -0
- data/features/modeling/example_output.feature +192 -0
- data/features/modeling/feature_file_modeling.feature +64 -0
- data/features/modeling/feature_file_output.feature +13 -0
- data/features/modeling/feature_modeling.feature +164 -0
- data/features/modeling/feature_output.feature +244 -0
- data/features/modeling/outline_modeling.feature +100 -0
- data/features/modeling/outline_output.feature +197 -0
- data/features/modeling/row_modeling.feature +77 -0
- data/features/modeling/row_output.feature +27 -0
- data/features/modeling/scenario_modeling.feature +89 -0
- data/features/modeling/scenario_output.feature +147 -0
- data/features/modeling/step_modeling.feature +85 -0
- data/features/modeling/step_output.feature +52 -0
- data/features/modeling/table_modeling.feature +52 -0
- data/features/modeling/table_output.feature +42 -0
- data/features/modeling/table_row_modeling.feature +67 -0
- data/features/modeling/table_row_output.feature +27 -0
- data/features/modeling/tag_modeling.feature +58 -0
- data/features/modeling/tag_output.feature +16 -0
- data/features/step_definitions/action_steps.rb +3 -0
- data/features/step_definitions/background_steps.rb +81 -0
- data/features/step_definitions/directory_steps.rb +52 -0
- data/features/step_definitions/doc_string_steps.rb +63 -0
- data/features/step_definitions/feature_file_steps.rb +41 -0
- data/features/step_definitions/feature_steps.rb +96 -0
- data/features/step_definitions/outline_steps.rb +252 -0
- data/features/step_definitions/setup_steps.rb +50 -0
- data/features/step_definitions/spec_steps.rb +18 -0
- data/features/step_definitions/step_steps.rb +159 -0
- data/features/step_definitions/table_steps.rb +54 -0
- data/features/step_definitions/tag_steps.rb +61 -0
- data/features/step_definitions/test_steps.rb +114 -0
- data/features/step_definitions/verification_steps.rb +9 -0
- data/features/support/env.rb +27 -0
- data/features/support/transforms.rb +3 -0
- data/lib/cuke_modeler.rb +29 -0
- data/lib/cuke_modeler/background.rb +38 -0
- data/lib/cuke_modeler/containing.rb +18 -0
- data/lib/cuke_modeler/directory.rb +86 -0
- data/lib/cuke_modeler/doc_string.rb +87 -0
- data/lib/cuke_modeler/example.rb +184 -0
- data/lib/cuke_modeler/feature.rb +147 -0
- data/lib/cuke_modeler/feature_element.rb +73 -0
- data/lib/cuke_modeler/feature_file.rb +77 -0
- data/lib/cuke_modeler/nested.rb +34 -0
- data/lib/cuke_modeler/outline.rb +68 -0
- data/lib/cuke_modeler/parsing.rb +32 -0
- data/lib/cuke_modeler/raw.rb +20 -0
- data/lib/cuke_modeler/row.rb +64 -0
- data/lib/cuke_modeler/scenario.rb +45 -0
- data/lib/cuke_modeler/sourceable.rb +20 -0
- data/lib/cuke_modeler/step.rb +214 -0
- data/lib/cuke_modeler/table.rb +90 -0
- data/lib/cuke_modeler/table_row.rb +64 -0
- data/lib/cuke_modeler/tag.rb +62 -0
- data/lib/cuke_modeler/taggable.rb +54 -0
- data/lib/cuke_modeler/test_element.rb +77 -0
- data/lib/cuke_modeler/version.rb +3 -0
- data/lib/cuke_modeler/world.rb +113 -0
- data/spec/integration/background_integration_spec.rb +72 -0
- data/spec/integration/directory_integration_spec.rb +48 -0
- data/spec/integration/doc_string_integration_spec.rb +66 -0
- data/spec/integration/example_integration_spec.rb +94 -0
- data/spec/integration/feature_file_integration_spec.rb +44 -0
- data/spec/integration/feature_integration_spec.rb +152 -0
- data/spec/integration/outline_integration_spec.rb +92 -0
- data/spec/integration/scenario_integration_spec.rb +80 -0
- data/spec/integration/step_integration_spec.rb +184 -0
- data/spec/integration/table_integration_spec.rb +86 -0
- data/spec/integration/table_row_integration_spec.rb +68 -0
- data/spec/integration/tag_integration_spec.rb +67 -0
- data/spec/integration/world_integration_spec.rb +13 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/unit/background_unit_spec.rb +55 -0
- data/spec/unit/bare_bones_unit_specs.rb +13 -0
- data/spec/unit/containing_element_unit_specs.rb +17 -0
- data/spec/unit/directory_unit_spec.rb +103 -0
- data/spec/unit/doc_string_unit_spec.rb +109 -0
- data/spec/unit/example_unit_spec.rb +251 -0
- data/spec/unit/feature_element_unit_spec.rb +19 -0
- data/spec/unit/feature_element_unit_specs.rb +46 -0
- data/spec/unit/feature_file_unit_spec.rb +94 -0
- data/spec/unit/feature_unit_spec.rb +135 -0
- data/spec/unit/nested_element_unit_specs.rb +36 -0
- data/spec/unit/nested_unit_spec.rb +37 -0
- data/spec/unit/outline_unit_spec.rb +91 -0
- data/spec/unit/parsing_unit_spec.rb +21 -0
- data/spec/unit/prepopulated_unit_specs.rb +13 -0
- data/spec/unit/raw_element_unit_specs.rb +24 -0
- data/spec/unit/raw_unit_spec.rb +25 -0
- data/spec/unit/row_unit_spec.rb +55 -0
- data/spec/unit/scenario_unit_spec.rb +71 -0
- data/spec/unit/sourceable_unit_spec.rb +17 -0
- data/spec/unit/sourced_element_unit_specs.rb +18 -0
- data/spec/unit/step_unit_spec.rb +259 -0
- data/spec/unit/table_row_unit_spec.rb +55 -0
- data/spec/unit/table_unit_spec.rb +96 -0
- data/spec/unit/tag_unit_spec.rb +51 -0
- data/spec/unit/taggable_unit_spec.rb +78 -0
- data/spec/unit/tagged_element_unit_specs.rb +63 -0
- data/spec/unit/test_element_unit_spec.rb +40 -0
- data/spec/unit/test_element_unit_specs.rb +31 -0
- data/spec/unit/world_unit_spec.rb +130 -0
- metadata +364 -0
@@ -0,0 +1,252 @@
|
|
1
|
+
When /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example blocks are as follows:$/ do |file, test, names|
|
2
|
+
file ||= 1
|
3
|
+
test ||= 1
|
4
|
+
|
5
|
+
expected = names.raw.flatten
|
6
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples.collect { |example| example.name }
|
7
|
+
|
8
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, example, properties|
|
12
|
+
file ||= 1
|
13
|
+
test ||= 1
|
14
|
+
example ||= 1
|
15
|
+
|
16
|
+
properties = properties.rows_hash
|
17
|
+
|
18
|
+
properties.each do |property, value|
|
19
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].send(property.to_sym).to_s.should == value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? row(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, example, row, properties|
|
24
|
+
file ||= 1
|
25
|
+
test ||= 1
|
26
|
+
example ||= 1
|
27
|
+
row ||= 1
|
28
|
+
|
29
|
+
properties = properties.rows_hash
|
30
|
+
|
31
|
+
properties.each do |property, value|
|
32
|
+
expected = value
|
33
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].row_elements[row - 1].send(property.to_sym).to_s
|
34
|
+
|
35
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has the following description:$/ do |file, test, example, text|
|
40
|
+
file ||= 1
|
41
|
+
test ||= 1
|
42
|
+
example ||= 1
|
43
|
+
|
44
|
+
new_description = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].description_text
|
45
|
+
old_description = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].description
|
46
|
+
|
47
|
+
new_description.should == text
|
48
|
+
old_description.should == remove_whitespace(text)
|
49
|
+
end
|
50
|
+
|
51
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has no description$/ do |file, test, example|
|
52
|
+
file ||= 1
|
53
|
+
test ||= 1
|
54
|
+
example ||= 1
|
55
|
+
|
56
|
+
new_description = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].description_text
|
57
|
+
old_description = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].description
|
58
|
+
|
59
|
+
new_description.should == ''
|
60
|
+
old_description.should == []
|
61
|
+
end
|
62
|
+
|
63
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? is found to have the following tags:$/ do |file, test, example, expected_tags|
|
64
|
+
file ||= 1
|
65
|
+
test ||= 1
|
66
|
+
example ||= 1
|
67
|
+
|
68
|
+
expected_tags = expected_tags.raw.flatten
|
69
|
+
|
70
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].tags.should == expected_tags
|
71
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].tag_elements.collect { |tag| tag.name }.should == expected_tags
|
72
|
+
end
|
73
|
+
|
74
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? is found to have the following applied tags:$/ do |file, test, example, expected_tags|
|
75
|
+
file ||= 1
|
76
|
+
test ||= 1
|
77
|
+
example ||= 1
|
78
|
+
|
79
|
+
expected_tags = expected_tags.raw.flatten.sort
|
80
|
+
|
81
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].applied_tags.sort.should == expected_tags
|
82
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].applied_tag_elements.collect { |tag| tag.name }.sort.should == expected_tags
|
83
|
+
end
|
84
|
+
|
85
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has no tags$/ do |file, test, example|
|
86
|
+
file ||= 1
|
87
|
+
test ||= 1
|
88
|
+
example ||= 1
|
89
|
+
|
90
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].tags.should == []
|
91
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].tag_elements.collect { |tag| tag.name }.should == []
|
92
|
+
end
|
93
|
+
|
94
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? rows are as follows:$/ do |file, test, example, rows|
|
95
|
+
file ||= 1
|
96
|
+
test ||= 1
|
97
|
+
example ||= 1
|
98
|
+
|
99
|
+
rows = rows.raw.flatten
|
100
|
+
example = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1]
|
101
|
+
|
102
|
+
expected = rows.collect { |row| row.split(',') }
|
103
|
+
|
104
|
+
actual = example.row_elements[1..example.row_elements.count].collect { |row| row.cells }
|
105
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
106
|
+
|
107
|
+
# todo - remove once Hash rows are no longer supported
|
108
|
+
actual = example.rows.collect { |row| example.parameters.collect { |parameter| row[parameter] } }
|
109
|
+
assert(actual == expected, "Expected: #{expected.inspect}\n but was: #{actual.inspect}")
|
110
|
+
end
|
111
|
+
|
112
|
+
When /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has the following rows added to it:$/ do |file, test, example, rows|
|
113
|
+
file ||= 1
|
114
|
+
test ||= 1
|
115
|
+
example ||= 1
|
116
|
+
|
117
|
+
rows = rows.raw.flatten
|
118
|
+
|
119
|
+
rows.each do |row|
|
120
|
+
row = row.split(',')
|
121
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].add_row(row)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
When /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has the following rows removed from it:$/ do |file, test, example, rows|
|
126
|
+
file ||= 1
|
127
|
+
test ||= 1
|
128
|
+
example ||= 1
|
129
|
+
|
130
|
+
rows = rows.raw.flatten
|
131
|
+
|
132
|
+
rows.each do |row|
|
133
|
+
row = row.split(',')
|
134
|
+
@parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].remove_row(row)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? parameters are as follows:$/ do |file, test, example, parameters|
|
139
|
+
file ||= 1
|
140
|
+
test ||= 1
|
141
|
+
example ||= 1
|
142
|
+
|
143
|
+
expected = parameters.raw.flatten
|
144
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].parameters
|
145
|
+
|
146
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
147
|
+
end
|
148
|
+
|
149
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? row(?: "([^"]*)")? cells are as follows:$/ do |file, test, example, row, cells|
|
150
|
+
file ||= 1
|
151
|
+
test ||= 1
|
152
|
+
example ||= 1
|
153
|
+
row ||= 1
|
154
|
+
|
155
|
+
expected = cells.raw.flatten
|
156
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].row_elements[row - 1].cells
|
157
|
+
|
158
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
159
|
+
end
|
160
|
+
|
161
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has no descriptive lines$/ do |file, test, example|
|
162
|
+
file ||= 1
|
163
|
+
test ||= 1
|
164
|
+
example ||= 1
|
165
|
+
|
166
|
+
assert @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].description == []
|
167
|
+
end
|
168
|
+
|
169
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has no parameters$/ do |file, test, example|
|
170
|
+
file ||= 1
|
171
|
+
test ||= 1
|
172
|
+
example ||= 1
|
173
|
+
|
174
|
+
assert @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].parameters == []
|
175
|
+
end
|
176
|
+
|
177
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? has no rows$/ do |file, test, example|
|
178
|
+
file ||= 1
|
179
|
+
test ||= 1
|
180
|
+
example ||= 1
|
181
|
+
|
182
|
+
example = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1]
|
183
|
+
|
184
|
+
example.row_elements[1..example.row_elements.count].should be_empty
|
185
|
+
#todo - remove once Hash rows are no longer supported
|
186
|
+
example.rows.should be_empty
|
187
|
+
end
|
188
|
+
|
189
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? row(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test, example, row|
|
190
|
+
file ||= 1
|
191
|
+
test ||= 1
|
192
|
+
example ||= 1
|
193
|
+
row ||= 1
|
194
|
+
|
195
|
+
raw_element = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].row_elements[row - 1].raw_element
|
196
|
+
|
197
|
+
raw_element.has_key?('cells').should be_true
|
198
|
+
end
|
199
|
+
|
200
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? example block(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test, example|
|
201
|
+
file ||= 1
|
202
|
+
test ||= 1
|
203
|
+
example ||= 1
|
204
|
+
|
205
|
+
raw_element = @parsed_files[file - 1].feature.tests[test - 1].examples[example - 1].raw_element
|
206
|
+
|
207
|
+
raw_element.has_key?('rows').should be_true
|
208
|
+
end
|
209
|
+
|
210
|
+
Then(/^the row has convenient output$/) do
|
211
|
+
@parsed_files.first.feature.tests.first.examples.first.row_elements.first.method(:to_s).owner.should == CukeModeler::Row
|
212
|
+
end
|
213
|
+
|
214
|
+
Given(/^a row element based on the following gherkin:$/) do |row_text|
|
215
|
+
@element = CukeModeler::Row.new(row_text)
|
216
|
+
end
|
217
|
+
|
218
|
+
Given(/^a row element$/) do
|
219
|
+
@element = CukeModeler::Row.new
|
220
|
+
end
|
221
|
+
|
222
|
+
When(/^the row element has no cells$/) do
|
223
|
+
@element.cells = []
|
224
|
+
end
|
225
|
+
|
226
|
+
Then(/^the example block has convenient output$/) do
|
227
|
+
@parsed_files.first.feature.tests.first.examples.first.method(:to_s).owner.should == CukeModeler::Example
|
228
|
+
end
|
229
|
+
|
230
|
+
Given(/^an example element based on the following gherkin:$/) do |example_text|
|
231
|
+
@element = CukeModeler::Example.new(example_text)
|
232
|
+
end
|
233
|
+
|
234
|
+
Given(/^an example element$/) do
|
235
|
+
@element = CukeModeler::Example.new
|
236
|
+
end
|
237
|
+
|
238
|
+
When(/^the example element has no parameters or rows$/) do
|
239
|
+
@element.parameters = []
|
240
|
+
|
241
|
+
#todo - remove once Hash rows are no longer supported
|
242
|
+
@element.rows = []
|
243
|
+
@element.row_elements = []
|
244
|
+
end
|
245
|
+
|
246
|
+
Then(/^the outline has convenient output$/) do
|
247
|
+
@parsed_files.first.feature.tests.first.method(:to_s).owner.should == CukeModeler::Outline
|
248
|
+
end
|
249
|
+
|
250
|
+
Given(/^an outline element based on the following gherkin:$/) do |outline_text|
|
251
|
+
@element = CukeModeler::Outline.new(outline_text)
|
252
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Given /^the following(?: feature)? file(?: "([^"]*)")?:$/ do |file_name, file_text|
|
2
|
+
@test_directory ||= @default_file_directory
|
3
|
+
file_name ||= @default_feature_file_name
|
4
|
+
|
5
|
+
File.open("#{@test_directory}/#{file_name}", 'w') { |file|
|
6
|
+
file.write(file_text)
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^the file(?: "([^"]*)")? is read$/ do |file_name|
|
11
|
+
@parsed_files ||= []
|
12
|
+
@test_directory ||= @default_file_directory
|
13
|
+
file_name ||= @default_feature_file_name
|
14
|
+
|
15
|
+
@parsed_files << CukeModeler::FeatureFile.new("#{@test_directory}/#{file_name}")
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^the step definition file "([^"]*)" is read$/ do |file_name|
|
19
|
+
@test_directory ||= @default_file_directory
|
20
|
+
file_name ||= @default_step_file_name
|
21
|
+
|
22
|
+
CukeModeler::World.load_step_file("#{@test_directory}/#{file_name}")
|
23
|
+
end
|
24
|
+
|
25
|
+
When /^parameter delimiters of "([^"]*)" and "([^"]*)"$/ do |left_delimiter, right_delimiter|
|
26
|
+
CukeModeler::World.left_delimiter = left_delimiter
|
27
|
+
CukeModeler::World.right_delimiter = right_delimiter
|
28
|
+
end
|
29
|
+
|
30
|
+
Given /^a directory "([^"]*)"$/ do |directory_name|
|
31
|
+
@test_directory = "#{@default_file_directory}/#{directory_name}"
|
32
|
+
|
33
|
+
FileUtils.mkdir(@test_directory) unless File.exists?(@test_directory)
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^the directory(?: "([^"]*)")? is read$/ do |directory_name|
|
37
|
+
@parsed_directories ||= []
|
38
|
+
@test_directory = "#{@default_file_directory}/#{directory_name}" if directory_name
|
39
|
+
|
40
|
+
@parsed_directories << CukeModeler::Directory.new(@test_directory)
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^the following step definition file(?: "([^"]*)")?:$/ do |file_name, file_text|
|
44
|
+
@test_directory ||= @default_file_directory
|
45
|
+
file_name ||= @default_step_file_name
|
46
|
+
|
47
|
+
File.open("#{@test_directory}/#{file_name}", 'w') { |file|
|
48
|
+
file.write(file_text)
|
49
|
+
}
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Given /^that there are "([^"]*)" detailing models$/ do |spec_file|
|
2
|
+
sub_directory = spec_file =~ /integration/ ? 'integration' : 'unit'
|
3
|
+
spec_file = "#{@spec_directory}/#{sub_directory}/#{spec_file}"
|
4
|
+
|
5
|
+
fail "The spec file does not exist: #{spec_file}" unless File.exists?(spec_file)
|
6
|
+
|
7
|
+
@spec_file = spec_file
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^the corresponding specifications are run$/ do
|
11
|
+
command = "rspec #{@spec_file}"
|
12
|
+
|
13
|
+
@specs_passed = system(command)
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^all of those specifications are met$/ do
|
17
|
+
fail "There were unmet specifications in '#{@spec_file}'." unless @specs_passed
|
18
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? keyword is "([^"]*)"$/ do |file, test, step, keyword|
|
2
|
+
file ||= 1
|
3
|
+
test ||= 1
|
4
|
+
step ||= 1
|
5
|
+
|
6
|
+
expected = keyword
|
7
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].keyword
|
8
|
+
|
9
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has the following block:$/ do |file, test, step, block|
|
13
|
+
file ||= 1
|
14
|
+
test ||= 1
|
15
|
+
step ||= 1
|
16
|
+
|
17
|
+
expected = block.raw.flatten.collect do |cell_value|
|
18
|
+
if cell_value.start_with? "'"
|
19
|
+
cell_value.slice(1..cell_value.length - 2)
|
20
|
+
else
|
21
|
+
cell_value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.flatten
|
26
|
+
|
27
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
28
|
+
end
|
29
|
+
|
30
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has no block$/ do |file, test, step|
|
31
|
+
file ||= 1
|
32
|
+
test ||= 1
|
33
|
+
step ||= 1
|
34
|
+
|
35
|
+
expected = nil
|
36
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block
|
37
|
+
|
38
|
+
actual.should == expected
|
39
|
+
end
|
40
|
+
|
41
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? text is "([^"]*)"$/ do |file, test, step, text|
|
42
|
+
file ||= 1
|
43
|
+
test ||= 1
|
44
|
+
step ||= 1
|
45
|
+
|
46
|
+
expected = text
|
47
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].base
|
48
|
+
|
49
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
50
|
+
end
|
51
|
+
|
52
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? arguments are:$/ do |file, test, step, arguments|
|
53
|
+
file ||= 1
|
54
|
+
test ||= 1
|
55
|
+
step ||= 1
|
56
|
+
|
57
|
+
expected = arguments.raw.flatten
|
58
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].arguments
|
59
|
+
|
60
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
61
|
+
end
|
62
|
+
|
63
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? has no arguments$/ do |file, test, step|
|
64
|
+
file ||= 1
|
65
|
+
test ||= 1
|
66
|
+
step ||= 1
|
67
|
+
|
68
|
+
expected = []
|
69
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].arguments
|
70
|
+
|
71
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
72
|
+
end
|
73
|
+
|
74
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? has a "([^"]*)"$/ do |file, test, step, type|
|
75
|
+
file ||= 1
|
76
|
+
test ||= 1
|
77
|
+
step ||= 1
|
78
|
+
|
79
|
+
case type
|
80
|
+
when 'doc string'
|
81
|
+
expected = CukeModeler::DocString
|
82
|
+
when 'table'
|
83
|
+
expected = CukeModeler::Table
|
84
|
+
else
|
85
|
+
raise(ArgumentError, "Unknown block type: #{type}")
|
86
|
+
end
|
87
|
+
|
88
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.class
|
89
|
+
|
90
|
+
actual.should == expected
|
91
|
+
end
|
92
|
+
|
93
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? source line is "([^"]*)"$/ do |file, test, step, line_number|
|
94
|
+
file ||= 1
|
95
|
+
test ||= 1
|
96
|
+
step ||= 1
|
97
|
+
|
98
|
+
expected = line_number.to_i
|
99
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].source_line
|
100
|
+
|
101
|
+
actual.should == expected
|
102
|
+
end
|
103
|
+
|
104
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?test(?: "([^"]*)")? step(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test, step|
|
105
|
+
file ||= 1
|
106
|
+
test ||= 1
|
107
|
+
step ||= 1
|
108
|
+
|
109
|
+
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].raw_element
|
110
|
+
|
111
|
+
raw_element.has_key?('keyword').should be_true
|
112
|
+
end
|
113
|
+
|
114
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? is found to have the following properties:$/ do |file, test, step, row, properties|
|
115
|
+
file ||= 1
|
116
|
+
test ||= 1
|
117
|
+
step ||= 1
|
118
|
+
row ||= 1
|
119
|
+
|
120
|
+
properties = properties.rows_hash
|
121
|
+
|
122
|
+
properties.each do |property, value|
|
123
|
+
expected = value
|
124
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].send(property.to_sym).to_s
|
125
|
+
|
126
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? correctly stores its underlying implementation$/ do |file, test, step, row|
|
131
|
+
file ||= 1
|
132
|
+
test ||= 1
|
133
|
+
step ||= 1
|
134
|
+
row ||= 1
|
135
|
+
|
136
|
+
raw_element = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].raw_element
|
137
|
+
|
138
|
+
raw_element.has_key?('cells').should be_true
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^(?:the )?(?:feature "([^"]*)" )?(?:test(?: "([^"]*)")? )?step(?: "([^"]*)")? table row(?: "([^"]*)")? cells are as follows:$/ do |file, test, step, row, cells|
|
142
|
+
file ||= 1
|
143
|
+
test ||= 1
|
144
|
+
step ||= 1
|
145
|
+
row ||= 1
|
146
|
+
|
147
|
+
expected = cells.raw.flatten
|
148
|
+
actual = @parsed_files[file - 1].feature.tests[test - 1].steps[step - 1].block.row_elements[row - 1].cells
|
149
|
+
|
150
|
+
assert(actual == expected, "Expected: #{expected}\n but was: #{actual}")
|
151
|
+
end
|
152
|
+
|
153
|
+
Given(/^a step element based on the following gherkin:$/) do |step_text|
|
154
|
+
@element = CukeModeler::Step.new(step_text)
|
155
|
+
end
|
156
|
+
|
157
|
+
Then(/^the step has convenient output$/) do
|
158
|
+
@parsed_files.first.feature.tests.first.steps.first.method(:to_s).owner.should == CukeModeler::Step
|
159
|
+
end
|