cuke_modeler 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +8 -0
- data/features/step_definitions/feature_steps.rb +1 -1
- data/features/step_definitions/test_steps.rb +6 -2
- data/lib/cuke_modeler/directory.rb +7 -10
- data/lib/cuke_modeler/version.rb +1 -1
- data/spec/integration/background_integration_spec.rb +53 -40
- data/spec/integration/directory_integration_spec.rb +39 -26
- data/spec/integration/doc_string_integration_spec.rb +51 -43
- data/spec/integration/example_integration_spec.rb +71 -60
- data/spec/integration/feature_file_integration_spec.rb +36 -22
- data/spec/integration/feature_integration_spec.rb +113 -104
- data/spec/integration/outline_integration_spec.rb +71 -56
- data/spec/integration/row_integration_spec.rb +72 -0
- data/spec/integration/scenario_integration_spec.rb +61 -46
- data/spec/integration/step_integration_spec.rb +126 -117
- data/spec/integration/table_integration_spec.rb +67 -52
- data/spec/integration/table_row_integration_spec.rb +48 -40
- data/spec/integration/tag_integration_spec.rb +53 -45
- data/spec/integration/world_integration_spec.rb +2 -1
- data/spec/spec_helper.rb +15 -12
- data/spec/unit/background_unit_spec.rb +65 -50
- data/spec/unit/bare_bones_unit_specs.rb +2 -3
- data/spec/unit/containing_element_unit_specs.rb +6 -7
- data/spec/unit/directory_unit_spec.rb +103 -64
- data/spec/unit/doc_string_unit_spec.rb +113 -95
- data/spec/unit/example_unit_spec.rb +235 -219
- data/spec/unit/feature_element_unit_spec.rb +6 -6
- data/spec/unit/feature_element_unit_specs.rb +28 -24
- data/spec/unit/feature_file_unit_spec.rb +73 -63
- data/spec/unit/feature_unit_spec.rb +145 -111
- data/spec/unit/nested_element_unit_specs.rb +14 -13
- data/spec/unit/nested_unit_spec.rb +24 -21
- data/spec/unit/outline_unit_spec.rb +92 -78
- data/spec/unit/parsing_unit_spec.rb +55 -51
- data/spec/unit/prepopulated_unit_specs.rb +2 -3
- data/spec/unit/raw_element_unit_specs.rb +12 -11
- data/spec/unit/raw_unit_spec.rb +15 -12
- data/spec/unit/row_unit_spec.rb +68 -52
- data/spec/unit/scenario_unit_spec.rb +76 -62
- data/spec/unit/sourceable_unit_spec.rb +8 -6
- data/spec/unit/sourced_element_unit_specs.rb +4 -6
- data/spec/unit/step_unit_spec.rb +231 -203
- data/spec/unit/table_row_unit_spec.rb +68 -52
- data/spec/unit/table_unit_spec.rb +100 -82
- data/spec/unit/tag_unit_spec.rb +62 -48
- data/spec/unit/taggable_unit_spec.rb +58 -51
- data/spec/unit/tagged_element_unit_specs.rb +28 -26
- data/spec/unit/test_element_unit_spec.rb +33 -27
- data/spec/unit/test_element_unit_specs.rb +15 -14
- data/spec/unit/world_unit_spec.rb +94 -84
- metadata +4 -2
data/spec/unit/step_unit_spec.rb
CHANGED
@@ -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
|
-
|
16
|
-
@step = clazz.new
|
17
|
-
end
|
11
|
+
describe 'common behavior' do
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
35
|
-
@step.should respond_to(:base)
|
36
|
-
end
|
22
|
+
describe 'unique behavior' do
|
37
23
|
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
46
|
-
|
47
|
-
end
|
28
|
+
it 'can change its arguments' do
|
29
|
+
expect(step).to respond_to(:arguments=)
|
48
30
|
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
41
|
+
it 'has a base' do
|
42
|
+
step.should respond_to(:base)
|
43
|
+
end
|
63
44
|
|
64
|
-
|
65
|
-
|
66
|
-
end
|
45
|
+
it 'can change its base' do
|
46
|
+
expect(step).to respond_to(:base=)
|
67
47
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
54
|
+
it 'starts with no base' do
|
55
|
+
step.base.should == nil
|
56
|
+
end
|
78
57
|
|
79
|
-
|
80
|
-
|
81
|
-
|
58
|
+
it 'has a block' do
|
59
|
+
step.should respond_to(:block)
|
60
|
+
end
|
82
61
|
|
83
|
-
|
84
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
71
|
+
it 'starts with no block' do
|
72
|
+
step.block.should == nil
|
73
|
+
end
|
97
74
|
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
-
|
106
|
-
|
107
|
-
end
|
79
|
+
it 'can change its keyword' do
|
80
|
+
expect(step).to respond_to(:keyword=)
|
108
81
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
88
|
+
it 'starts with no keyword' do
|
89
|
+
step.keyword.should == nil
|
90
|
+
end
|
116
91
|
|
117
|
-
it '
|
118
|
-
|
92
|
+
it 'has a left delimiter' do
|
93
|
+
step.should respond_to(:left_delimiter)
|
119
94
|
end
|
120
95
|
|
121
|
-
it 'can
|
122
|
-
|
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.
|
126
|
-
step.
|
127
|
-
step.
|
128
|
-
step.
|
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 '
|
132
|
-
|
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
|
-
|
137
|
-
step.
|
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
|
143
|
-
|
113
|
+
it 'can change its right delimiter' do
|
114
|
+
expect(step).to respond_to(:right_delimiter=)
|
144
115
|
|
145
|
-
step =
|
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
|
-
|
148
|
-
step.
|
122
|
+
it 'starts with no right delimiter' do
|
123
|
+
step.right_delimiter.should == nil
|
149
124
|
end
|
150
125
|
|
151
|
-
it 'can
|
152
|
-
|
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
|
-
|
132
|
+
describe '#scan_arguments' do
|
155
133
|
|
156
|
-
|
157
|
-
|
158
|
-
|
134
|
+
it 'can explicitly scan for arguments' do
|
135
|
+
step.should respond_to(:scan_arguments)
|
136
|
+
end
|
159
137
|
|
160
|
-
|
161
|
-
|
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
|
-
|
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
|
-
|
166
|
-
|
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
|
-
|
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
|
-
|
174
|
-
|
175
|
-
|
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
|
-
|
178
|
-
|
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
|
-
|
182
|
-
source = '* test step'
|
162
|
+
step = clazz.new(source)
|
183
163
|
|
184
|
-
|
164
|
+
step.scan_arguments('!', '-')
|
165
|
+
step.arguments.should == ['a parameter']
|
166
|
+
end
|
185
167
|
|
186
|
-
|
187
|
-
|
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
|
-
|
191
|
-
source = "bad step text\n And a step\n @foo"
|
171
|
+
step = clazz.new(source)
|
192
172
|
|
193
|
-
|
194
|
-
|
173
|
+
step.scan_arguments('-start-', '-end-')
|
174
|
+
step.arguments.should == ['a parameter']
|
175
|
+
end
|
195
176
|
|
196
|
-
|
197
|
-
|
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
|
-
|
201
|
-
expect(raw_data[:type]).to eq(:Step)
|
202
|
-
end
|
180
|
+
step = clazz.new(source)
|
203
181
|
|
204
|
-
|
205
|
-
|
206
|
-
|
182
|
+
step.scan_arguments('\d+', '.?')
|
183
|
+
step.arguments.should == ['a parameter']
|
184
|
+
end
|
207
185
|
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
|
213
|
-
|
214
|
-
|
190
|
+
step.left_delimiter = '"'
|
191
|
+
step.right_delimiter = '"'
|
192
|
+
step.scan_arguments
|
215
193
|
|
216
|
-
|
217
|
-
|
218
|
-
|
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
|
-
|
201
|
+
expect { @element = clazz.new(source) }.to_not raise_error
|
222
202
|
|
223
|
-
|
224
|
-
|
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 '
|
230
|
-
|
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
|
-
|
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 '
|
238
|
-
|
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 '
|
242
|
-
|
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
|
-
|
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 '
|
248
|
-
|
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
|
-
|
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
|
-
|
257
|
-
end
|
238
|
+
describe '#step_text' do
|
258
239
|
|
259
|
-
|
260
|
-
|
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
|
-
|
247
|
+
it 'can provide different flavors of step\'s text' do
|
248
|
+
step.should respond_to(:step_text)
|
249
|
+
end
|
266
250
|
|
267
|
-
|
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
|
-
|
270
|
-
|
271
|
-
|
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
|
-
|
274
|
-
|
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
|
-
|
278
|
-
|
262
|
+
step.step_text(:with_arguments => false).should == expected_output
|
263
|
+
end
|
279
264
|
|
280
|
-
|
281
|
-
|
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
|
-
|
284
|
-
|
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
|
-
|
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
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
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
|