cuke_modeler 0.0.1

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 (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.simplecov +8 -0
  4. data/Gemfile +4 -0
  5. data/History.rdoc +3 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +73 -0
  8. data/Rakefile +38 -0
  9. data/cuke_modeler.gemspec +29 -0
  10. data/features/analysis/test_comparison.feature +123 -0
  11. data/features/analysis/test_manipulation.feature +37 -0
  12. data/features/modeling/background_modeling.feature +75 -0
  13. data/features/modeling/background_output.feature +130 -0
  14. data/features/modeling/directory_modeling.feature +120 -0
  15. data/features/modeling/directory_output.feature +13 -0
  16. data/features/modeling/doc_string_modeling.feature +63 -0
  17. data/features/modeling/doc_string_output.feature +71 -0
  18. data/features/modeling/example_modeling.feature +111 -0
  19. data/features/modeling/example_output.feature +192 -0
  20. data/features/modeling/feature_file_modeling.feature +64 -0
  21. data/features/modeling/feature_file_output.feature +13 -0
  22. data/features/modeling/feature_modeling.feature +164 -0
  23. data/features/modeling/feature_output.feature +244 -0
  24. data/features/modeling/outline_modeling.feature +100 -0
  25. data/features/modeling/outline_output.feature +197 -0
  26. data/features/modeling/row_modeling.feature +77 -0
  27. data/features/modeling/row_output.feature +27 -0
  28. data/features/modeling/scenario_modeling.feature +89 -0
  29. data/features/modeling/scenario_output.feature +147 -0
  30. data/features/modeling/step_modeling.feature +85 -0
  31. data/features/modeling/step_output.feature +52 -0
  32. data/features/modeling/table_modeling.feature +52 -0
  33. data/features/modeling/table_output.feature +42 -0
  34. data/features/modeling/table_row_modeling.feature +67 -0
  35. data/features/modeling/table_row_output.feature +27 -0
  36. data/features/modeling/tag_modeling.feature +58 -0
  37. data/features/modeling/tag_output.feature +16 -0
  38. data/features/step_definitions/action_steps.rb +3 -0
  39. data/features/step_definitions/background_steps.rb +81 -0
  40. data/features/step_definitions/directory_steps.rb +52 -0
  41. data/features/step_definitions/doc_string_steps.rb +63 -0
  42. data/features/step_definitions/feature_file_steps.rb +41 -0
  43. data/features/step_definitions/feature_steps.rb +96 -0
  44. data/features/step_definitions/outline_steps.rb +252 -0
  45. data/features/step_definitions/setup_steps.rb +50 -0
  46. data/features/step_definitions/spec_steps.rb +18 -0
  47. data/features/step_definitions/step_steps.rb +159 -0
  48. data/features/step_definitions/table_steps.rb +54 -0
  49. data/features/step_definitions/tag_steps.rb +61 -0
  50. data/features/step_definitions/test_steps.rb +114 -0
  51. data/features/step_definitions/verification_steps.rb +9 -0
  52. data/features/support/env.rb +27 -0
  53. data/features/support/transforms.rb +3 -0
  54. data/lib/cuke_modeler.rb +29 -0
  55. data/lib/cuke_modeler/background.rb +38 -0
  56. data/lib/cuke_modeler/containing.rb +18 -0
  57. data/lib/cuke_modeler/directory.rb +86 -0
  58. data/lib/cuke_modeler/doc_string.rb +87 -0
  59. data/lib/cuke_modeler/example.rb +184 -0
  60. data/lib/cuke_modeler/feature.rb +147 -0
  61. data/lib/cuke_modeler/feature_element.rb +73 -0
  62. data/lib/cuke_modeler/feature_file.rb +77 -0
  63. data/lib/cuke_modeler/nested.rb +34 -0
  64. data/lib/cuke_modeler/outline.rb +68 -0
  65. data/lib/cuke_modeler/parsing.rb +32 -0
  66. data/lib/cuke_modeler/raw.rb +20 -0
  67. data/lib/cuke_modeler/row.rb +64 -0
  68. data/lib/cuke_modeler/scenario.rb +45 -0
  69. data/lib/cuke_modeler/sourceable.rb +20 -0
  70. data/lib/cuke_modeler/step.rb +214 -0
  71. data/lib/cuke_modeler/table.rb +90 -0
  72. data/lib/cuke_modeler/table_row.rb +64 -0
  73. data/lib/cuke_modeler/tag.rb +62 -0
  74. data/lib/cuke_modeler/taggable.rb +54 -0
  75. data/lib/cuke_modeler/test_element.rb +77 -0
  76. data/lib/cuke_modeler/version.rb +3 -0
  77. data/lib/cuke_modeler/world.rb +113 -0
  78. data/spec/integration/background_integration_spec.rb +72 -0
  79. data/spec/integration/directory_integration_spec.rb +48 -0
  80. data/spec/integration/doc_string_integration_spec.rb +66 -0
  81. data/spec/integration/example_integration_spec.rb +94 -0
  82. data/spec/integration/feature_file_integration_spec.rb +44 -0
  83. data/spec/integration/feature_integration_spec.rb +152 -0
  84. data/spec/integration/outline_integration_spec.rb +92 -0
  85. data/spec/integration/scenario_integration_spec.rb +80 -0
  86. data/spec/integration/step_integration_spec.rb +184 -0
  87. data/spec/integration/table_integration_spec.rb +86 -0
  88. data/spec/integration/table_row_integration_spec.rb +68 -0
  89. data/spec/integration/tag_integration_spec.rb +67 -0
  90. data/spec/integration/world_integration_spec.rb +13 -0
  91. data/spec/spec_helper.rb +30 -0
  92. data/spec/unit/background_unit_spec.rb +55 -0
  93. data/spec/unit/bare_bones_unit_specs.rb +13 -0
  94. data/spec/unit/containing_element_unit_specs.rb +17 -0
  95. data/spec/unit/directory_unit_spec.rb +103 -0
  96. data/spec/unit/doc_string_unit_spec.rb +109 -0
  97. data/spec/unit/example_unit_spec.rb +251 -0
  98. data/spec/unit/feature_element_unit_spec.rb +19 -0
  99. data/spec/unit/feature_element_unit_specs.rb +46 -0
  100. data/spec/unit/feature_file_unit_spec.rb +94 -0
  101. data/spec/unit/feature_unit_spec.rb +135 -0
  102. data/spec/unit/nested_element_unit_specs.rb +36 -0
  103. data/spec/unit/nested_unit_spec.rb +37 -0
  104. data/spec/unit/outline_unit_spec.rb +91 -0
  105. data/spec/unit/parsing_unit_spec.rb +21 -0
  106. data/spec/unit/prepopulated_unit_specs.rb +13 -0
  107. data/spec/unit/raw_element_unit_specs.rb +24 -0
  108. data/spec/unit/raw_unit_spec.rb +25 -0
  109. data/spec/unit/row_unit_spec.rb +55 -0
  110. data/spec/unit/scenario_unit_spec.rb +71 -0
  111. data/spec/unit/sourceable_unit_spec.rb +17 -0
  112. data/spec/unit/sourced_element_unit_specs.rb +18 -0
  113. data/spec/unit/step_unit_spec.rb +259 -0
  114. data/spec/unit/table_row_unit_spec.rb +55 -0
  115. data/spec/unit/table_unit_spec.rb +96 -0
  116. data/spec/unit/tag_unit_spec.rb +51 -0
  117. data/spec/unit/taggable_unit_spec.rb +78 -0
  118. data/spec/unit/tagged_element_unit_specs.rb +63 -0
  119. data/spec/unit/test_element_unit_spec.rb +40 -0
  120. data/spec/unit/test_element_unit_specs.rb +31 -0
  121. data/spec/unit/world_unit_spec.rb +130 -0
  122. 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