cuke_modeler 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +8 -0
  3. data/features/step_definitions/feature_steps.rb +1 -1
  4. data/features/step_definitions/test_steps.rb +6 -2
  5. data/lib/cuke_modeler/directory.rb +7 -10
  6. data/lib/cuke_modeler/version.rb +1 -1
  7. data/spec/integration/background_integration_spec.rb +53 -40
  8. data/spec/integration/directory_integration_spec.rb +39 -26
  9. data/spec/integration/doc_string_integration_spec.rb +51 -43
  10. data/spec/integration/example_integration_spec.rb +71 -60
  11. data/spec/integration/feature_file_integration_spec.rb +36 -22
  12. data/spec/integration/feature_integration_spec.rb +113 -104
  13. data/spec/integration/outline_integration_spec.rb +71 -56
  14. data/spec/integration/row_integration_spec.rb +72 -0
  15. data/spec/integration/scenario_integration_spec.rb +61 -46
  16. data/spec/integration/step_integration_spec.rb +126 -117
  17. data/spec/integration/table_integration_spec.rb +67 -52
  18. data/spec/integration/table_row_integration_spec.rb +48 -40
  19. data/spec/integration/tag_integration_spec.rb +53 -45
  20. data/spec/integration/world_integration_spec.rb +2 -1
  21. data/spec/spec_helper.rb +15 -12
  22. data/spec/unit/background_unit_spec.rb +65 -50
  23. data/spec/unit/bare_bones_unit_specs.rb +2 -3
  24. data/spec/unit/containing_element_unit_specs.rb +6 -7
  25. data/spec/unit/directory_unit_spec.rb +103 -64
  26. data/spec/unit/doc_string_unit_spec.rb +113 -95
  27. data/spec/unit/example_unit_spec.rb +235 -219
  28. data/spec/unit/feature_element_unit_spec.rb +6 -6
  29. data/spec/unit/feature_element_unit_specs.rb +28 -24
  30. data/spec/unit/feature_file_unit_spec.rb +73 -63
  31. data/spec/unit/feature_unit_spec.rb +145 -111
  32. data/spec/unit/nested_element_unit_specs.rb +14 -13
  33. data/spec/unit/nested_unit_spec.rb +24 -21
  34. data/spec/unit/outline_unit_spec.rb +92 -78
  35. data/spec/unit/parsing_unit_spec.rb +55 -51
  36. data/spec/unit/prepopulated_unit_specs.rb +2 -3
  37. data/spec/unit/raw_element_unit_specs.rb +12 -11
  38. data/spec/unit/raw_unit_spec.rb +15 -12
  39. data/spec/unit/row_unit_spec.rb +68 -52
  40. data/spec/unit/scenario_unit_spec.rb +76 -62
  41. data/spec/unit/sourceable_unit_spec.rb +8 -6
  42. data/spec/unit/sourced_element_unit_specs.rb +4 -6
  43. data/spec/unit/step_unit_spec.rb +231 -203
  44. data/spec/unit/table_row_unit_spec.rb +68 -52
  45. data/spec/unit/table_unit_spec.rb +100 -82
  46. data/spec/unit/tag_unit_spec.rb +62 -48
  47. data/spec/unit/taggable_unit_spec.rb +58 -51
  48. data/spec/unit/tagged_element_unit_specs.rb +28 -26
  49. data/spec/unit/test_element_unit_spec.rb +33 -27
  50. data/spec/unit/test_element_unit_specs.rb +15 -14
  51. data/spec/unit/world_unit_spec.rb +94 -84
  52. metadata +4 -2
@@ -5,295 +5,323 @@ SimpleCov.command_name('Step') unless RUBY_VERSION.to_s < '1.9.0'
5
5
  describe 'Step, Unit' do
6
6
 
7
7
  let(:clazz) { CukeModeler::Step }
8
+ let(:step) { clazz.new }
8
9
 
9
- it_should_behave_like 'a nested element'
10
- it_should_behave_like 'a bare bones element'
11
- it_should_behave_like 'a prepopulated element'
12
- it_should_behave_like 'a sourced element'
13
- it_should_behave_like 'a raw element'
14
10
 
15
- before(:each) do
16
- @step = clazz.new
17
- end
11
+ describe 'common behavior' do
18
12
 
19
- it 'has arguments - #arguments' do
20
- @step.should respond_to(:arguments)
21
- end
13
+ it_should_behave_like 'a nested element'
14
+ it_should_behave_like 'a bare bones element'
15
+ it_should_behave_like 'a prepopulated element'
16
+ it_should_behave_like 'a sourced element'
17
+ it_should_behave_like 'a raw element'
22
18
 
23
- it 'can get and set its arguments - #arguments, #arguments=' do
24
- @step.arguments = :some_arguments
25
- @step.arguments.should == :some_arguments
26
- @step.arguments = :some_other_arguments
27
- @step.arguments.should == :some_other_arguments
28
19
  end
29
20
 
30
- it 'starts with no arguments' do
31
- @step.arguments.should == []
32
- end
33
21
 
34
- it 'has a base - #base' do
35
- @step.should respond_to(:base)
36
- end
22
+ describe 'unique behavior' do
37
23
 
38
- it 'can get and set its base - #base, #base=' do
39
- @step.base = :some_base
40
- @step.base.should == :some_base
41
- @step.base = :some_other_base
42
- @step.base.should == :some_other_base
43
- end
24
+ it 'has arguments' do
25
+ step.should respond_to(:arguments)
26
+ end
44
27
 
45
- it 'starts with no base' do
46
- @step.base.should == nil
47
- end
28
+ it 'can change its arguments' do
29
+ expect(step).to respond_to(:arguments=)
48
30
 
49
- it 'has a block - #block' do
50
- @step.should respond_to(:block)
51
- end
31
+ step.arguments = :some_arguments
32
+ step.arguments.should == :some_arguments
33
+ step.arguments = :some_other_arguments
34
+ step.arguments.should == :some_other_arguments
35
+ end
52
36
 
53
- it 'can get and set its block - #block, #block=' do
54
- @step.block = :some_block
55
- @step.block.should == :some_block
56
- @step.block = :some_other_block
57
- @step.block.should == :some_other_block
58
- end
37
+ it 'starts with no arguments' do
38
+ step.arguments.should == []
39
+ end
59
40
 
60
- it 'starts with no block' do
61
- @step.block.should == nil
62
- end
41
+ it 'has a base' do
42
+ step.should respond_to(:base)
43
+ end
63
44
 
64
- it 'has a keyword - #keyword' do
65
- @step.should respond_to(:keyword)
66
- end
45
+ it 'can change its base' do
46
+ expect(step).to respond_to(:base=)
67
47
 
68
- it 'can get and set its keyword - #keyword, #keyword=' do
69
- @step.keyword = :some_keyword
70
- @step.keyword.should == :some_keyword
71
- @step.keyword = :some_other_keyword
72
- @step.keyword.should == :some_other_keyword
73
- end
48
+ step.base = :some_base
49
+ step.base.should == :some_base
50
+ step.base = :some_other_base
51
+ step.base.should == :some_other_base
52
+ end
74
53
 
75
- it 'starts with no keyword' do
76
- @step.keyword.should == nil
77
- end
54
+ it 'starts with no base' do
55
+ step.base.should == nil
56
+ end
78
57
 
79
- it 'has a left delimiter - #left_delimiter' do
80
- @step.should respond_to(:left_delimiter)
81
- end
58
+ it 'has a block' do
59
+ step.should respond_to(:block)
60
+ end
82
61
 
83
- it 'can get and set its left delimiter - #left_delimiter, #left_delimiter=' do
84
- @step.left_delimiter = :some_left_delimiter
85
- @step.left_delimiter.should == :some_left_delimiter
86
- @step.left_delimiter = :some_other_left_delimiter
87
- @step.left_delimiter.should == :some_other_left_delimiter
88
- end
62
+ it 'can change its block' do
63
+ expect(step).to respond_to(:block=)
89
64
 
90
- it 'starts with no left delimiter' do
91
- @step.left_delimiter.should == nil
92
- end
65
+ step.block = :some_block
66
+ step.block.should == :some_block
67
+ step.block = :some_other_block
68
+ step.block.should == :some_other_block
69
+ end
93
70
 
94
- it 'has a right delimiter - #right_delimiter' do
95
- @step.should respond_to(:right_delimiter)
96
- end
71
+ it 'starts with no block' do
72
+ step.block.should == nil
73
+ end
97
74
 
98
- it 'can get and set its right delimiter - #right_delimiter, #right_delimiter=' do
99
- @step.right_delimiter = :some_right_delimiter
100
- @step.right_delimiter.should == :some_right_delimiter
101
- @step.right_delimiter = :some_other_right_delimiter
102
- @step.right_delimiter.should == :some_other_right_delimiter
103
- end
75
+ it 'has a keyword' do
76
+ step.should respond_to(:keyword)
77
+ end
104
78
 
105
- it 'starts with no right delimiter' do
106
- @step.right_delimiter.should == nil
107
- end
79
+ it 'can change its keyword' do
80
+ expect(step).to respond_to(:keyword=)
108
81
 
109
- it 'can set both of its delimiters at once - #delimiter=' do
110
- @step.delimiter = :new_delimiter
111
- @step.left_delimiter.should == :new_delimiter
112
- @step.right_delimiter.should == :new_delimiter
113
- end
82
+ step.keyword = :some_keyword
83
+ step.keyword.should == :some_keyword
84
+ step.keyword = :some_other_keyword
85
+ step.keyword.should == :some_other_keyword
86
+ end
114
87
 
115
- context '#scan_arguments' do
88
+ it 'starts with no keyword' do
89
+ step.keyword.should == nil
90
+ end
116
91
 
117
- it 'can explicitly scan for arguments' do
118
- @step.should respond_to(:scan_arguments)
92
+ it 'has a left delimiter' do
93
+ step.should respond_to(:left_delimiter)
119
94
  end
120
95
 
121
- it 'can determine its arguments based on a regular expression' do
122
- source = 'Given a test step with a parameter'
123
- step = CukeModeler::Step.new(source)
96
+ it 'can change its left delimiter' do
97
+ expect(step).to respond_to(:left_delimiter=)
124
98
 
125
- step.scan_arguments(/parameter/)
126
- step.arguments.should == ['parameter']
127
- step.scan_arguments(/t s/)
128
- step.arguments.should == ['t s']
99
+ step.left_delimiter = :some_left_delimiter
100
+ step.left_delimiter.should == :some_left_delimiter
101
+ step.left_delimiter = :some_other_left_delimiter
102
+ step.left_delimiter.should == :some_other_left_delimiter
129
103
  end
130
104
 
131
- it 'can determine its arguments based on delimiters' do
132
- source = 'Given a test step with -parameter 1- and -parameter 2-'
133
-
134
- step = CukeModeler::Step.new(source)
105
+ it 'starts with no left delimiter' do
106
+ step.left_delimiter.should == nil
107
+ end
135
108
 
136
- step.scan_arguments('-', '-')
137
- step.arguments.should == ['parameter 1', 'parameter 2']
138
- step.scan_arguments('!', '!')
139
- step.arguments.should == []
109
+ it 'has a right delimiter' do
110
+ step.should respond_to(:right_delimiter)
140
111
  end
141
112
 
142
- it 'can use different left and right delimiters when scanning' do
143
- source = 'Given a test step with !a parameter-'
113
+ it 'can change its right delimiter' do
114
+ expect(step).to respond_to(:right_delimiter=)
144
115
 
145
- step = CukeModeler::Step.new(source)
116
+ step.right_delimiter = :some_right_delimiter
117
+ step.right_delimiter.should == :some_right_delimiter
118
+ step.right_delimiter = :some_other_right_delimiter
119
+ step.right_delimiter.should == :some_other_right_delimiter
120
+ end
146
121
 
147
- step.scan_arguments('!', '-')
148
- step.arguments.should == ['a parameter']
122
+ it 'starts with no right delimiter' do
123
+ step.right_delimiter.should == nil
149
124
  end
150
125
 
151
- it 'can use delimiters of varying lengths' do
152
- source = 'Given a test step with -start-a parameter-end-'
126
+ it 'can set both of its delimiters at once' do
127
+ step.delimiter = :new_delimiter
128
+ step.left_delimiter.should == :new_delimiter
129
+ step.right_delimiter.should == :new_delimiter
130
+ end
153
131
 
154
- step = CukeModeler::Step.new(source)
132
+ describe '#scan_arguments' do
155
133
 
156
- step.scan_arguments('-start-', '-end-')
157
- step.arguments.should == ['a parameter']
158
- end
134
+ it 'can explicitly scan for arguments' do
135
+ step.should respond_to(:scan_arguments)
136
+ end
159
137
 
160
- it 'can handle delimiters with special regular expression characters' do
161
- source = 'Given a test step with \d+a parameter.?'
138
+ it 'can determine its arguments based on a regular expression' do
139
+ source = 'Given a test step with a parameter'
140
+ step = clazz.new(source)
162
141
 
163
- step = CukeModeler::Step.new(source)
142
+ step.scan_arguments(/parameter/)
143
+ step.arguments.should == ['parameter']
144
+ step.scan_arguments(/t s/)
145
+ step.arguments.should == ['t s']
146
+ end
164
147
 
165
- step.scan_arguments('\d+', '.?')
166
- step.arguments.should == ['a parameter']
167
- end
148
+ it 'can determine its arguments based on delimiters' do
149
+ source = 'Given a test step with -parameter 1- and -parameter 2-'
168
150
 
169
- it 'defaults to its set delimiters when scanning' do
170
- source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
171
- step = CukeModeler::Step.new(source)
151
+ step = clazz.new(source)
172
152
 
173
- step.left_delimiter = '"'
174
- step.right_delimiter = '"'
175
- step.scan_arguments
153
+ step.scan_arguments('-', '-')
154
+ step.arguments.should == ['parameter 1', 'parameter 2']
155
+ step.scan_arguments('!', '!')
156
+ step.arguments.should == []
157
+ end
176
158
 
177
- step.arguments.should == ['parameter 2']
178
- end
179
- end
159
+ it 'can use different left and right delimiters when scanning' do
160
+ source = 'Given a test step with !a parameter-'
180
161
 
181
- it 'can be parsed from stand alone text' do
182
- source = '* test step'
162
+ step = clazz.new(source)
183
163
 
184
- expect { @element = clazz.new(source) }.to_not raise_error
164
+ step.scan_arguments('!', '-')
165
+ step.arguments.should == ['a parameter']
166
+ end
185
167
 
186
- # Sanity check in case instantiation failed in a non-explosive manner
187
- @element.base.should == 'test step'
188
- end
168
+ it 'can use delimiters of varying lengths' do
169
+ source = 'Given a test step with -start-a parameter-end-'
189
170
 
190
- it 'provides a descriptive filename when being parsed from stand alone text' do
191
- source = "bad step text\n And a step\n @foo"
171
+ step = clazz.new(source)
192
172
 
193
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_step\.feature'/)
194
- end
173
+ step.scan_arguments('-start-', '-end-')
174
+ step.arguments.should == ['a parameter']
175
+ end
195
176
 
196
- it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
197
- step = clazz.new("* test step")
198
- raw_data = step.raw_element
177
+ it 'can handle delimiters with special regular expression characters' do
178
+ source = 'Given a test step with \d+a parameter.?'
199
179
 
200
- expect(raw_data.keys).to match_array([:type, :location, :keyword, :text])
201
- expect(raw_data[:type]).to eq(:Step)
202
- end
180
+ step = clazz.new(source)
203
181
 
204
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
205
- step = clazz.new("* test step")
206
- raw_data = step.raw_element
182
+ step.scan_arguments('\d+', '.?')
183
+ step.arguments.should == ['a parameter']
184
+ end
207
185
 
208
- expect(raw_data.keys).to match_array([:type, :location, :keyword, :text])
209
- expect(raw_data[:type]).to eq(:Step)
210
- end
186
+ it 'defaults to its set delimiters when scanning' do
187
+ source = 'Given a test step with *parameter 1* and "parameter 2" and *parameter 3*'
188
+ step = clazz.new(source)
211
189
 
212
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
213
- step = clazz.new("* test step")
214
- raw_data = step.raw_element
190
+ step.left_delimiter = '"'
191
+ step.right_delimiter = '"'
192
+ step.scan_arguments
215
193
 
216
- expect(raw_data.keys).to match_array(['keyword', 'name', 'line'])
217
- expect(raw_data['keyword']).to eq('* ')
218
- end
194
+ step.arguments.should == ['parameter 2']
195
+ end
196
+ end
219
197
 
198
+ it 'can be parsed from stand alone text' do
199
+ source = '* test step'
220
200
 
221
- context '#step_text' do
201
+ expect { @element = clazz.new(source) }.to_not raise_error
222
202
 
223
- before(:each) do
224
- source = "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|"
225
- @step = CukeModeler::Step.new(source)
226
- @step.delimiter = '-'
203
+ # Sanity check in case instantiation failed in a non-explosive manner
204
+ @element.base.should == 'test step'
227
205
  end
228
206
 
229
- it 'can provide different flavors of step\'s text' do
230
- @step.should respond_to(:step_text)
231
- end
207
+ it 'provides a descriptive filename when being parsed from stand alone text' do
208
+ source = "bad step text\n And a step\n @foo"
232
209
 
233
- it 'returns different text based on options' do
234
- (clazz.instance_method(:step_text).arity != 0).should be_true
210
+ expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_step\.feature'/)
235
211
  end
236
212
 
237
- it 'returns the step\'s text as an Array' do
238
- @step.step_text.is_a?(Array).should be_true
213
+ it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
214
+ step = clazz.new("* test step")
215
+ raw_data = step.raw_element
216
+
217
+ expect(raw_data.keys).to match_array([:type, :location, :keyword, :text])
218
+ expect(raw_data[:type]).to eq(:Step)
239
219
  end
240
220
 
241
- it 'can provide the step\'s text without the arguments' do
242
- expected_output = ['Given a test step with -- ^and@ *parameter 2!!']
221
+ it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
222
+ step = clazz.new("* test step")
223
+ raw_data = step.raw_element
243
224
 
244
- @step.step_text(:with_arguments => false).should == expected_output
225
+ expect(raw_data.keys).to match_array([:type, :location, :keyword, :text])
226
+ expect(raw_data[:type]).to eq(:Step)
245
227
  end
246
228
 
247
- it 'can determine its arguments based on delimiters' do
248
- expected_output = ['Given a test step with -parameter 1- ^@ *parameter 2!!']
229
+ it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
230
+ step = clazz.new("* test step")
231
+ raw_data = step.raw_element
249
232
 
250
- @step.step_text(:with_arguments => false, :left_delimiter => '^', :right_delimiter => '@').should == expected_output
233
+ expect(raw_data.keys).to match_array(['keyword', 'name', 'line'])
234
+ expect(raw_data['keyword']).to eq('* ')
251
235
  end
252
236
 
253
- it 'can use delimiters of varying lengths' do
254
- expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
255
237
 
256
- @step.step_text(:with_arguments => false, :left_delimiter => '*', :right_delimiter => '!!').should == expected_output
257
- end
238
+ describe '#step_text' do
258
239
 
259
- it 'can handle delimiters with special regular expression characters' do
260
- expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
240
+ let(:source) { "Given a test step with -parameter 1- ^and@ *parameter 2!!\n|a block|" }
241
+ let(:delimiter) { '-' }
242
+ let(:step) { s = clazz.new(source)
243
+ s.delimiter = delimiter
244
+ s }
261
245
 
262
- @step.step_text(:with_arguments => false, :left_delimiter => '*', :right_delimiter => '!!').should == expected_output
263
- end
264
246
 
265
- end
247
+ it 'can provide different flavors of step\'s text' do
248
+ step.should respond_to(:step_text)
249
+ end
266
250
 
267
- context 'step output edge cases' do
251
+ it 'returns different text based on options' do
252
+ (clazz.instance_method(:step_text).arity != 0).should be_true
253
+ end
268
254
 
269
- it 'is a String' do
270
- @step.to_s.should be_a(String)
271
- end
255
+ it 'returns the step\'s text as an Array' do
256
+ step.step_text.is_a?(Array).should be_true
257
+ end
272
258
 
273
- it 'can output an empty step' do
274
- expect { @step.to_s }.to_not raise_error
275
- end
259
+ it 'can provide the step\'s text without the arguments' do
260
+ expected_output = ['Given a test step with -- ^and@ *parameter 2!!']
276
261
 
277
- it 'can output a step that has only a keyword' do
278
- @step.keyword = '*'
262
+ step.step_text(:with_arguments => false).should == expected_output
263
+ end
279
264
 
280
- expect { @step.to_s }.to_not raise_error
281
- end
265
+ it 'can determine its arguments based on delimiters' do
266
+ expected_output = ['Given a test step with -parameter 1- ^@ *parameter 2!!']
267
+
268
+ step.step_text(:with_arguments => false, :left_delimiter => '^', :right_delimiter => '@').should == expected_output
269
+ end
282
270
 
283
- it 'can output a step that has only a base' do
284
- @step.base = 'step base'
271
+ it 'can use delimiters of varying lengths' do
272
+ expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
273
+
274
+ step.step_text(:with_arguments => false, :left_delimiter => '*', :right_delimiter => '!!').should == expected_output
275
+ end
276
+
277
+ it 'can handle delimiters with special regular expression characters' do
278
+ expected_output = ['Given a test step with -parameter 1- ^and@ *!!']
279
+
280
+ step.step_text(:with_arguments => false, :left_delimiter => '*', :right_delimiter => '!!').should == expected_output
281
+ end
285
282
 
286
- expect { @step.to_s }.to_not raise_error
287
283
  end
288
284
 
289
- end
285
+ describe 'step output edge cases' do
286
+
287
+ it 'is a String' do
288
+ step.to_s.should be_a(String)
289
+ end
290
+
291
+
292
+ context 'a new step object' do
293
+
294
+ let(:step) { clazz.new }
295
+
290
296
 
291
- it 'can gracefully be compared to other types of objects' do
292
- # Some common types of object
293
- [1, 'foo', :bar, [], {}].each do |thing|
294
- expect { @step == thing }.to_not raise_error
295
- expect(@step == thing).to be false
297
+ it 'can output an empty step' do
298
+ expect { step.to_s }.to_not raise_error
299
+ end
300
+
301
+ it 'can output a step that has only a keyword' do
302
+ step.keyword = '*'
303
+
304
+ expect { step.to_s }.to_not raise_error
305
+ end
306
+
307
+ it 'can output a step that has only a base' do
308
+ step.base = 'step base'
309
+
310
+ expect { step.to_s }.to_not raise_error
311
+ end
312
+
313
+ end
314
+
315
+ end
316
+
317
+ it 'can gracefully be compared to other types of objects' do
318
+ # Some common types of object
319
+ [1, 'foo', :bar, [], {}].each do |thing|
320
+ expect { step == thing }.to_not raise_error
321
+ expect(step == thing).to be false
322
+ end
296
323
  end
324
+
297
325
  end
298
326
 
299
327
  end