cuke_modeler 2.1.0 → 3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -1
- data/README.md +14 -16
- data/cuke_modeler.gemspec +33 -21
- data/lib/cuke_modeler.rb +2 -1
- data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +13 -0
- data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +13 -0
- data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +13 -0
- data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +13 -0
- data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +13 -0
- data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +13 -0
- data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +356 -4
- data/lib/cuke_modeler/containing.rb +41 -89
- data/lib/cuke_modeler/described.rb +40 -1
- data/lib/cuke_modeler/models/background.rb +12 -12
- data/lib/cuke_modeler/models/cell.rb +14 -8
- data/lib/cuke_modeler/models/comment.rb +6 -6
- data/lib/cuke_modeler/models/directory.rb +14 -18
- data/lib/cuke_modeler/models/doc_string.rb +11 -8
- data/lib/cuke_modeler/models/example.rb +64 -46
- data/lib/cuke_modeler/models/feature.rb +38 -20
- data/lib/cuke_modeler/models/feature_file.rb +6 -8
- data/lib/cuke_modeler/models/model.rb +2 -1
- data/lib/cuke_modeler/models/outline.rb +20 -15
- data/lib/cuke_modeler/models/row.rb +11 -8
- data/lib/cuke_modeler/models/rule.rb +101 -0
- data/lib/cuke_modeler/models/scenario.rb +18 -13
- data/lib/cuke_modeler/models/step.rb +41 -19
- data/lib/cuke_modeler/models/table.rb +10 -7
- data/lib/cuke_modeler/models/tag.rb +10 -6
- data/lib/cuke_modeler/named.rb +5 -1
- data/lib/cuke_modeler/nested.rb +22 -18
- data/lib/cuke_modeler/parsed.rb +8 -0
- data/lib/cuke_modeler/parsing.rb +55 -74
- data/lib/cuke_modeler/sourceable.rb +8 -0
- data/lib/cuke_modeler/stepped.rb +8 -0
- data/lib/cuke_modeler/taggable.rb +9 -1
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
- data/testing/cucumber/features/modeling/feature_output.feature +45 -23
- data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
- data/testing/cucumber/features/modeling/rule_output.feature +111 -0
- metadata +68 -161
- data/.gitignore +0 -18
- data/.simplecov +0 -7
- data/.travis.yml +0 -81
- data/Gemfile +0 -44
- data/Rakefile +0 -73
- data/appveyor.yml +0 -88
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
- data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +0 -12
- data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +0 -310
- data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +0 -307
- data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +0 -12
- data/testing/cucumber/step_definitions/action_steps.rb +0 -13
- data/testing/cucumber/step_definitions/background_steps.rb +0 -1
- data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
- data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
- data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
- data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
- data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
- data/testing/cucumber/step_definitions/step_steps.rb +0 -3
- data/testing/cucumber/step_definitions/table_steps.rb +0 -1
- data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
- data/testing/cucumber/support/env.rb +0 -30
- data/testing/dialect_helper.rb +0 -48
- data/testing/file_helper.rb +0 -47
- data/testing/gemfiles/gherkin2.gemfile +0 -33
- data/testing/gemfiles/gherkin3.gemfile +0 -26
- data/testing/gemfiles/gherkin4.gemfile +0 -27
- data/testing/gemfiles/gherkin5.gemfile +0 -27
- data/testing/gemfiles/gherkin6.gemfile +0 -10
- data/testing/gemfiles/gherkin7.gemfile +0 -9
- data/testing/gemfiles/gherkin8.gemfile +0 -9
- data/testing/gemfiles/gherkin9.gemfile +0 -9
- data/testing/helper_methods.rb +0 -23
- data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
- data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +0 -165
- data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -159
- data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +0 -162
- data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +0 -162
- data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +0 -162
- data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -438
- data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -338
- data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -180
- data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
- data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -398
- data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -753
- data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -276
- data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -655
- data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
- data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -619
- data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -303
- data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -475
- data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -573
- data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -333
- data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -271
- data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -143
- data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
- data/testing/rspec/spec/spec_helper.rb +0 -129
- data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
- data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
- data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
- data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
- data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
- data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
- data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
- data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
- data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
- data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
- data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
- data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
- data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
- data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
- data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
- data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
- data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
- data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
- data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
- data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
- data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
- data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
- data/testing/test_languages.json +0 -45
- data/todo.txt +0 -25
@@ -1,303 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Row, Integration' do
|
5
|
-
|
6
|
-
let(:clazz) { CukeModeler::Row }
|
7
|
-
|
8
|
-
|
9
|
-
describe 'common behavior' do
|
10
|
-
|
11
|
-
it_should_behave_like 'a model, integration'
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
describe 'unique behavior' do
|
17
|
-
|
18
|
-
it 'can be instantiated with the minimum viable Gherkin' do
|
19
|
-
source = '| a | row |'
|
20
|
-
|
21
|
-
expect { clazz.new(source) }.to_not raise_error
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'can parse text that uses a non-default dialect' do
|
25
|
-
original_dialect = CukeModeler::Parsing.dialect
|
26
|
-
CukeModeler::Parsing.dialect = 'en-au'
|
27
|
-
|
28
|
-
begin
|
29
|
-
source_text = '| a | row |'
|
30
|
-
|
31
|
-
expect { @model = clazz.new(source_text) }.to_not raise_error
|
32
|
-
|
33
|
-
# Sanity check in case modeling failed in a non-explosive manner
|
34
|
-
expect(@model.cells.last.value).to eq('row')
|
35
|
-
ensure
|
36
|
-
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
37
|
-
CukeModeler::Parsing.dialect = original_dialect
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'provides a descriptive filename when being parsed from stand alone text' do
|
42
|
-
source = " |bad |row| text| \n @foo "
|
43
|
-
|
44
|
-
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_row\.feature'/)
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'parsing data' do
|
48
|
-
|
49
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(8, 9) do
|
50
|
-
example_row = clazz.new("| a | row |")
|
51
|
-
data = example_row.parsing_data
|
52
|
-
|
53
|
-
expect(data.keys).to match_array([:location, :cells, :id])
|
54
|
-
expect(data[:location][:line]).to eq(5)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7) do
|
58
|
-
example_row = clazz.new("| a | row |")
|
59
|
-
data = example_row.parsing_data
|
60
|
-
|
61
|
-
expect(data.keys).to match_array([:location, :cells])
|
62
|
-
expect(data[:location][:line]).to eq(5)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(4, 5) do
|
66
|
-
example_row = clazz.new("| a | row |")
|
67
|
-
data = example_row.parsing_data
|
68
|
-
|
69
|
-
expect(data.keys).to match_array([:type, :location, :cells])
|
70
|
-
expect(data[:type]).to eq(:TableRow)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(3) do
|
74
|
-
example_row = clazz.new("| a | row |")
|
75
|
-
data = example_row.parsing_data
|
76
|
-
|
77
|
-
expect(data.keys).to match_array([:type, :location, :cells])
|
78
|
-
expect(data[:type]).to eq('TableRow')
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
|
82
|
-
example_row = clazz.new("| a | row |")
|
83
|
-
data = example_row.parsing_data
|
84
|
-
|
85
|
-
expect(data.keys).to match_array(['cells', 'line'])
|
86
|
-
expect(data['line']).to eq(5)
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'properly sets its child models' do
|
92
|
-
source = '| cell 1 | cell 2 |'
|
93
|
-
|
94
|
-
row = clazz.new(source)
|
95
|
-
cell_1 = row.cells.first
|
96
|
-
cell_2 = row.cells.last
|
97
|
-
|
98
|
-
expect(cell_1.parent_model).to equal(row)
|
99
|
-
expect(cell_2.parent_model).to equal(row)
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
describe 'getting ancestors' do
|
104
|
-
|
105
|
-
before(:each) do
|
106
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'row_test_file', :directory => test_directory)
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
111
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
112
|
-
|
113
|
-
#{SCENARIO_KEYWORD}: Test test
|
114
|
-
#{STEP_KEYWORD} a step:
|
115
|
-
| a | table |"
|
116
|
-
}
|
117
|
-
|
118
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
119
|
-
let(:row_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first }
|
120
|
-
|
121
|
-
|
122
|
-
it 'can get its directory' do
|
123
|
-
ancestor = row_model.get_ancestor(:directory)
|
124
|
-
|
125
|
-
expect(ancestor).to equal(directory_model)
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'can get its feature file' do
|
129
|
-
ancestor = row_model.get_ancestor(:feature_file)
|
130
|
-
|
131
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'can get its feature' do
|
135
|
-
ancestor = row_model.get_ancestor(:feature)
|
136
|
-
|
137
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'can get its step' do
|
141
|
-
ancestor = row_model.get_ancestor(:step)
|
142
|
-
|
143
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'can get its table' do
|
147
|
-
ancestor = row_model.get_ancestor(:table)
|
148
|
-
|
149
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block)
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'a row that is part of a scenario' do
|
153
|
-
|
154
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
155
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
156
|
-
|
157
|
-
#{SCENARIO_KEYWORD}: Test test
|
158
|
-
#{STEP_KEYWORD} a step:
|
159
|
-
| a | table |"
|
160
|
-
}
|
161
|
-
|
162
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
163
|
-
let(:row_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first }
|
164
|
-
|
165
|
-
|
166
|
-
it 'can get its scenario' do
|
167
|
-
ancestor = row_model.get_ancestor(:scenario)
|
168
|
-
|
169
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
|
175
|
-
context 'a row that is part of a background' do
|
176
|
-
|
177
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
178
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
179
|
-
|
180
|
-
#{BACKGROUND_KEYWORD}: Test background
|
181
|
-
#{STEP_KEYWORD} a step:
|
182
|
-
| a | table |"
|
183
|
-
}
|
184
|
-
|
185
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
186
|
-
let(:row_model) { directory_model.feature_files.first.feature.background.steps.first.block.rows.first }
|
187
|
-
|
188
|
-
|
189
|
-
it 'can get its background' do
|
190
|
-
ancestor = row_model.get_ancestor(:background)
|
191
|
-
|
192
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
|
193
|
-
end
|
194
|
-
|
195
|
-
end
|
196
|
-
|
197
|
-
context 'a row that is part of an outline' do
|
198
|
-
|
199
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
200
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
201
|
-
|
202
|
-
#{OUTLINE_KEYWORD}: Test outline
|
203
|
-
#{STEP_KEYWORD} a step
|
204
|
-
#{EXAMPLE_KEYWORD}:
|
205
|
-
| param |
|
206
|
-
| value |"
|
207
|
-
}
|
208
|
-
|
209
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
210
|
-
let(:row_model) { directory_model.feature_files.first.feature.tests.first.examples.first.rows.first }
|
211
|
-
|
212
|
-
|
213
|
-
it 'can get its outline' do
|
214
|
-
ancestor = row_model.get_ancestor(:outline)
|
215
|
-
|
216
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
217
|
-
end
|
218
|
-
|
219
|
-
it 'can get its example' do
|
220
|
-
ancestor = row_model.get_ancestor(:example)
|
221
|
-
|
222
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first)
|
223
|
-
end
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
228
|
-
ancestor = row_model.get_ancestor(:outline)
|
229
|
-
|
230
|
-
expect(ancestor).to be_nil
|
231
|
-
end
|
232
|
-
|
233
|
-
end
|
234
|
-
|
235
|
-
|
236
|
-
describe 'model population' do
|
237
|
-
|
238
|
-
context 'from source text' do
|
239
|
-
|
240
|
-
let(:source_text) { '| cell 1 | cell 2 |' }
|
241
|
-
let(:row) { clazz.new(source_text) }
|
242
|
-
|
243
|
-
|
244
|
-
it "models the row's cells" do
|
245
|
-
cell_values = row.cells.collect { |cell| cell.value }
|
246
|
-
|
247
|
-
expect(cell_values).to match_array(['cell 1', 'cell 2'])
|
248
|
-
end
|
249
|
-
|
250
|
-
it "models the row's source line" do
|
251
|
-
source_text = "#{FEATURE_KEYWORD}: Test feature
|
252
|
-
|
253
|
-
#{OUTLINE_KEYWORD}: Test outline
|
254
|
-
#{STEP_KEYWORD} a step
|
255
|
-
#{EXAMPLE_KEYWORD}:
|
256
|
-
| param |
|
257
|
-
| value |"
|
258
|
-
row = CukeModeler::Feature.new(source_text).tests.first.examples.first.rows.first
|
259
|
-
|
260
|
-
expect(row.source_line).to eq(6)
|
261
|
-
end
|
262
|
-
|
263
|
-
end
|
264
|
-
|
265
|
-
end
|
266
|
-
|
267
|
-
|
268
|
-
describe 'row output' do
|
269
|
-
|
270
|
-
it 'can be remade from its own output' do
|
271
|
-
source = "| value1 | value2 |"
|
272
|
-
row = clazz.new(source)
|
273
|
-
|
274
|
-
row_output = row.to_s
|
275
|
-
remade_row_output = clazz.new(row_output).to_s
|
276
|
-
|
277
|
-
expect(remade_row_output).to eq(row_output)
|
278
|
-
end
|
279
|
-
|
280
|
-
|
281
|
-
context 'from source text' do
|
282
|
-
|
283
|
-
it 'can output a row' do
|
284
|
-
source = '| some value |'
|
285
|
-
row = clazz.new(source)
|
286
|
-
|
287
|
-
expect(row.to_s).to eq('| some value |')
|
288
|
-
end
|
289
|
-
|
290
|
-
it 'can output a row with multiple cells' do
|
291
|
-
source = '| some value | some other value |'
|
292
|
-
row = clazz.new(source)
|
293
|
-
|
294
|
-
expect(row.to_s).to eq('| some value | some other value |')
|
295
|
-
end
|
296
|
-
|
297
|
-
end
|
298
|
-
|
299
|
-
end
|
300
|
-
|
301
|
-
end
|
302
|
-
|
303
|
-
end
|
@@ -1,475 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Scenario, Integration' do
|
5
|
-
|
6
|
-
let(:clazz) { CukeModeler::Scenario }
|
7
|
-
|
8
|
-
|
9
|
-
describe 'common behavior' do
|
10
|
-
|
11
|
-
it_should_behave_like 'a model, integration'
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'unique behavior' do
|
16
|
-
|
17
|
-
it 'can be instantiated with the minimum viable Gherkin' do
|
18
|
-
source = "#{SCENARIO_KEYWORD}:"
|
19
|
-
|
20
|
-
expect { clazz.new(source) }.to_not raise_error
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'can parse text that uses a non-default dialect' do
|
24
|
-
original_dialect = CukeModeler::Parsing.dialect
|
25
|
-
CukeModeler::Parsing.dialect = 'en-au'
|
26
|
-
|
27
|
-
begin
|
28
|
-
source_text = 'Awww, look mate: Scenario name'
|
29
|
-
|
30
|
-
expect { @model = clazz.new(source_text) }.to_not raise_error
|
31
|
-
|
32
|
-
# Sanity check in case modeling failed in a non-explosive manner
|
33
|
-
expect(@model.name).to eq('Scenario name')
|
34
|
-
ensure
|
35
|
-
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
36
|
-
CukeModeler::Parsing.dialect = original_dialect
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'provides a descriptive filename when being parsed from stand alone text' do
|
41
|
-
source = "bad scenario text \n #{SCENARIO_KEYWORD}:\n And a step\n @foo "
|
42
|
-
|
43
|
-
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_scenario\.feature'/)
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'parsing data' do
|
47
|
-
|
48
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
|
49
|
-
scenario = clazz.new("@tag\n#{SCENARIO_KEYWORD}: test scenario\ndescription\n#{STEP_KEYWORD} a step")
|
50
|
-
data = scenario.parsing_data
|
51
|
-
|
52
|
-
expect(data.keys).to match_array([:background, :rule, :scenario])
|
53
|
-
expect(data[:scenario][:name]).to eq('test scenario')
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(3, 4, 5) do
|
57
|
-
scenario = clazz.new("@tag\n#{SCENARIO_KEYWORD}: test scenario\ndescription\n#{STEP_KEYWORD} a step")
|
58
|
-
data = scenario.parsing_data
|
59
|
-
|
60
|
-
expect(data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps, :description])
|
61
|
-
expect(data[:type]).to eq(:Scenario)
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
|
65
|
-
scenario = clazz.new("@tag\n#{SCENARIO_KEYWORD}: test scenario\ndescription\n#{STEP_KEYWORD} a step")
|
66
|
-
data = scenario.parsing_data
|
67
|
-
|
68
|
-
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'type', 'steps', 'tags'])
|
69
|
-
expect(data['keyword']).to eq('Scenario')
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'properly sets its child models' do
|
75
|
-
source = "@a_tag
|
76
|
-
#{SCENARIO_KEYWORD}: Test scenario
|
77
|
-
#{STEP_KEYWORD} a step"
|
78
|
-
|
79
|
-
scenario = clazz.new(source)
|
80
|
-
step = scenario.steps.first
|
81
|
-
tag = scenario.tags.first
|
82
|
-
|
83
|
-
expect(step.parent_model).to equal(scenario)
|
84
|
-
expect(tag.parent_model).to equal(scenario)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'trims whitespace from its source description' do
|
88
|
-
source = ["#{SCENARIO_KEYWORD}:",
|
89
|
-
' ',
|
90
|
-
' description line 1',
|
91
|
-
'',
|
92
|
-
' description line 2',
|
93
|
-
' description line 3 ',
|
94
|
-
'',
|
95
|
-
'',
|
96
|
-
'',
|
97
|
-
" #{STEP_KEYWORD} a step"]
|
98
|
-
source = source.join("\n")
|
99
|
-
|
100
|
-
scenario = clazz.new(source)
|
101
|
-
description = scenario.description.split("\n", -1)
|
102
|
-
|
103
|
-
expect(description).to eq([' description line 1',
|
104
|
-
'',
|
105
|
-
'description line 2',
|
106
|
-
' description line 3'])
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
describe 'getting ancestors' do
|
111
|
-
|
112
|
-
before(:each) do
|
113
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'scenario_test_file', :directory => test_directory)
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
118
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
119
|
-
|
120
|
-
#{SCENARIO_KEYWORD}: Test test
|
121
|
-
#{STEP_KEYWORD} a step"
|
122
|
-
}
|
123
|
-
|
124
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
125
|
-
let(:scenario_model) { directory_model.feature_files.first.feature.tests.first }
|
126
|
-
|
127
|
-
|
128
|
-
it 'can get its directory' do
|
129
|
-
ancestor = scenario_model.get_ancestor(:directory)
|
130
|
-
|
131
|
-
expect(ancestor).to equal(directory_model)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'can get its feature file' do
|
135
|
-
ancestor = scenario_model.get_ancestor(:feature_file)
|
136
|
-
|
137
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'can get its feature' do
|
141
|
-
ancestor = scenario_model.get_ancestor(:feature)
|
142
|
-
|
143
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
147
|
-
ancestor = scenario_model.get_ancestor(:test)
|
148
|
-
|
149
|
-
expect(ancestor).to be_nil
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
|
155
|
-
describe 'model population' do
|
156
|
-
|
157
|
-
context 'from source text' do
|
158
|
-
|
159
|
-
let(:source_text) { "#{SCENARIO_KEYWORD}:" }
|
160
|
-
let(:scenario) { clazz.new(source_text) }
|
161
|
-
|
162
|
-
|
163
|
-
it "models the scenario's keyword" do
|
164
|
-
expect(scenario.keyword).to eq("#{SCENARIO_KEYWORD}")
|
165
|
-
end
|
166
|
-
|
167
|
-
it "models the scenario's source line" do
|
168
|
-
source_text = "#{FEATURE_KEYWORD}:
|
169
|
-
|
170
|
-
#{SCENARIO_KEYWORD}: foo
|
171
|
-
#{STEP_KEYWORD} step"
|
172
|
-
scenario = CukeModeler::Feature.new(source_text).tests.first
|
173
|
-
|
174
|
-
expect(scenario.source_line).to eq(3)
|
175
|
-
end
|
176
|
-
|
177
|
-
|
178
|
-
context 'a filled scenario' do
|
179
|
-
|
180
|
-
let(:source_text) { "@tag1 @tag2 @tag3
|
181
|
-
#{SCENARIO_KEYWORD}: Scenario name
|
182
|
-
|
183
|
-
Scenario description.
|
184
|
-
|
185
|
-
Some more.
|
186
|
-
Even more.
|
187
|
-
|
188
|
-
#{STEP_KEYWORD} a step
|
189
|
-
#{STEP_KEYWORD} another step" }
|
190
|
-
let(:scenario) { clazz.new(source_text) }
|
191
|
-
|
192
|
-
|
193
|
-
it "models the scenario's name" do
|
194
|
-
expect(scenario.name).to eq('Scenario name')
|
195
|
-
end
|
196
|
-
|
197
|
-
it "models the scenario's description" do
|
198
|
-
description = scenario.description.split("\n", -1)
|
199
|
-
|
200
|
-
expect(description).to eq([' Scenario description.',
|
201
|
-
'',
|
202
|
-
'Some more.',
|
203
|
-
' Even more.'])
|
204
|
-
end
|
205
|
-
|
206
|
-
it "models the scenario's steps" do
|
207
|
-
step_names = scenario.steps.collect { |step| step.text }
|
208
|
-
|
209
|
-
expect(step_names).to eq(['a step', 'another step'])
|
210
|
-
end
|
211
|
-
|
212
|
-
it "models the scenario's tags" do
|
213
|
-
tag_names = scenario.tags.collect { |tag| tag.name }
|
214
|
-
|
215
|
-
expect(tag_names).to eq(['@tag1', '@tag2', '@tag3'])
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|
219
|
-
|
220
|
-
context 'an empty scenario' do
|
221
|
-
|
222
|
-
let(:source_text) { "#{SCENARIO_KEYWORD}:" }
|
223
|
-
let(:scenario) { clazz.new(source_text) }
|
224
|
-
|
225
|
-
|
226
|
-
it "models the scenario's name" do
|
227
|
-
expect(scenario.name).to eq('')
|
228
|
-
end
|
229
|
-
|
230
|
-
it "models the scenario's description" do
|
231
|
-
expect(scenario.description).to eq('')
|
232
|
-
end
|
233
|
-
|
234
|
-
it "models the scenario's steps" do
|
235
|
-
expect(scenario.steps).to eq([])
|
236
|
-
end
|
237
|
-
|
238
|
-
it "models the scenario's tags" do
|
239
|
-
expect(scenario.tags).to eq([])
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
end
|
245
|
-
|
246
|
-
end
|
247
|
-
|
248
|
-
|
249
|
-
describe 'comparison' do
|
250
|
-
|
251
|
-
it 'is equal to a background with the same steps' do
|
252
|
-
source = "#{SCENARIO_KEYWORD}:
|
253
|
-
#{STEP_KEYWORD} step 1
|
254
|
-
#{STEP_KEYWORD} step 2"
|
255
|
-
scenario = clazz.new(source)
|
256
|
-
|
257
|
-
source = "#{BACKGROUND_KEYWORD}:
|
258
|
-
#{STEP_KEYWORD} step 1
|
259
|
-
#{STEP_KEYWORD} step 2"
|
260
|
-
background_1 = CukeModeler::Background.new(source)
|
261
|
-
|
262
|
-
source = "#{BACKGROUND_KEYWORD}:
|
263
|
-
#{STEP_KEYWORD} step 2
|
264
|
-
#{STEP_KEYWORD} step 1"
|
265
|
-
background_2 = CukeModeler::Background.new(source)
|
266
|
-
|
267
|
-
|
268
|
-
expect(scenario).to eq(background_1)
|
269
|
-
expect(scenario).to_not eq(background_2)
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'is equal to a scenario with the same steps' do
|
273
|
-
source = "#{SCENARIO_KEYWORD}:
|
274
|
-
#{STEP_KEYWORD} step 1
|
275
|
-
#{STEP_KEYWORD} step 2"
|
276
|
-
scenario_1 = clazz.new(source)
|
277
|
-
|
278
|
-
source = "#{SCENARIO_KEYWORD}:
|
279
|
-
#{STEP_KEYWORD} step 1
|
280
|
-
#{STEP_KEYWORD} step 2"
|
281
|
-
scenario_2 = clazz.new(source)
|
282
|
-
|
283
|
-
source = "#{SCENARIO_KEYWORD}:
|
284
|
-
#{STEP_KEYWORD} step 2
|
285
|
-
#{STEP_KEYWORD} step 1"
|
286
|
-
scenario_3 = clazz.new(source)
|
287
|
-
|
288
|
-
|
289
|
-
expect(scenario_1).to eq(scenario_2)
|
290
|
-
expect(scenario_1).to_not eq(scenario_3)
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'is equal to an outline with the same steps' do
|
294
|
-
source = "#{SCENARIO_KEYWORD}:
|
295
|
-
#{STEP_KEYWORD} step 1
|
296
|
-
#{STEP_KEYWORD} step 2"
|
297
|
-
scenario = clazz.new(source)
|
298
|
-
|
299
|
-
source = "#{OUTLINE_KEYWORD}:
|
300
|
-
#{STEP_KEYWORD} step 1
|
301
|
-
#{STEP_KEYWORD} step 2
|
302
|
-
#{EXAMPLE_KEYWORD}:
|
303
|
-
| param |
|
304
|
-
| value |"
|
305
|
-
outline_1 = CukeModeler::Outline.new(source)
|
306
|
-
|
307
|
-
source = "#{OUTLINE_KEYWORD}:
|
308
|
-
#{STEP_KEYWORD} step 2
|
309
|
-
#{STEP_KEYWORD} step 1
|
310
|
-
#{EXAMPLE_KEYWORD}:
|
311
|
-
| param |
|
312
|
-
| value |"
|
313
|
-
outline_2 = CukeModeler::Outline.new(source)
|
314
|
-
|
315
|
-
|
316
|
-
expect(scenario).to eq(outline_1)
|
317
|
-
expect(scenario).to_not eq(outline_2)
|
318
|
-
end
|
319
|
-
|
320
|
-
end
|
321
|
-
|
322
|
-
|
323
|
-
describe 'scenario output' do
|
324
|
-
|
325
|
-
it 'can be remade from its own output' do
|
326
|
-
source = "@tag1 @tag2 @tag3
|
327
|
-
#{SCENARIO_KEYWORD}: A scenario with everything it could have
|
328
|
-
|
329
|
-
Including a description
|
330
|
-
and then some.
|
331
|
-
|
332
|
-
#{STEP_KEYWORD} a step
|
333
|
-
| value |
|
334
|
-
#{STEP_KEYWORD} another step
|
335
|
-
\"\"\"
|
336
|
-
some string
|
337
|
-
\"\"\""
|
338
|
-
scenario = clazz.new(source)
|
339
|
-
|
340
|
-
scenario_output = scenario.to_s
|
341
|
-
remade_scenario_output = clazz.new(scenario_output).to_s
|
342
|
-
|
343
|
-
expect(remade_scenario_output).to eq(scenario_output)
|
344
|
-
end
|
345
|
-
|
346
|
-
|
347
|
-
context 'from source text' do
|
348
|
-
|
349
|
-
it 'can output an empty scenario' do
|
350
|
-
source = ["#{SCENARIO_KEYWORD}:"]
|
351
|
-
source = source.join("\n")
|
352
|
-
scenario = clazz.new(source)
|
353
|
-
|
354
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
355
|
-
|
356
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}:"])
|
357
|
-
end
|
358
|
-
|
359
|
-
it 'can output a scenario that has a name' do
|
360
|
-
source = ["#{SCENARIO_KEYWORD}: test scenario"]
|
361
|
-
source = source.join("\n")
|
362
|
-
scenario = clazz.new(source)
|
363
|
-
|
364
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
365
|
-
|
366
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}: test scenario"])
|
367
|
-
end
|
368
|
-
|
369
|
-
it 'can output a scenario that has a description' do
|
370
|
-
source = ["#{SCENARIO_KEYWORD}:",
|
371
|
-
'Some description.',
|
372
|
-
'Some more description.']
|
373
|
-
source = source.join("\n")
|
374
|
-
scenario = clazz.new(source)
|
375
|
-
|
376
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
377
|
-
|
378
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}:",
|
379
|
-
'',
|
380
|
-
'Some description.',
|
381
|
-
'Some more description.'])
|
382
|
-
end
|
383
|
-
|
384
|
-
it 'can output a scenario that has steps' do
|
385
|
-
source = ["#{SCENARIO_KEYWORD}:",
|
386
|
-
"#{STEP_KEYWORD} a step",
|
387
|
-
'|value|',
|
388
|
-
"#{STEP_KEYWORD} another step",
|
389
|
-
'"""',
|
390
|
-
'some string',
|
391
|
-
'"""']
|
392
|
-
source = source.join("\n")
|
393
|
-
scenario = clazz.new(source)
|
394
|
-
|
395
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
396
|
-
|
397
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}:",
|
398
|
-
" #{STEP_KEYWORD} a step",
|
399
|
-
' | value |',
|
400
|
-
" #{STEP_KEYWORD} another step",
|
401
|
-
' """',
|
402
|
-
' some string',
|
403
|
-
' """'])
|
404
|
-
end
|
405
|
-
|
406
|
-
it 'can output a scenario that has tags' do
|
407
|
-
source = ['@tag1 @tag2',
|
408
|
-
'@tag3',
|
409
|
-
"#{SCENARIO_KEYWORD}:"]
|
410
|
-
source = source.join("\n")
|
411
|
-
scenario = clazz.new(source)
|
412
|
-
|
413
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
414
|
-
|
415
|
-
expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
|
416
|
-
"#{SCENARIO_KEYWORD}:"])
|
417
|
-
end
|
418
|
-
|
419
|
-
it 'can output a scenario that has everything' do
|
420
|
-
source = ['@tag1 @tag2 @tag3',
|
421
|
-
"#{SCENARIO_KEYWORD}: A scenario with everything it could have",
|
422
|
-
'Including a description',
|
423
|
-
'and then some.',
|
424
|
-
"#{STEP_KEYWORD} a step",
|
425
|
-
'|value|',
|
426
|
-
"#{STEP_KEYWORD} another step",
|
427
|
-
'"""',
|
428
|
-
'some string',
|
429
|
-
'"""']
|
430
|
-
source = source.join("\n")
|
431
|
-
scenario = clazz.new(source)
|
432
|
-
|
433
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
434
|
-
|
435
|
-
expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
|
436
|
-
"#{SCENARIO_KEYWORD}: A scenario with everything it could have",
|
437
|
-
'',
|
438
|
-
'Including a description',
|
439
|
-
'and then some.',
|
440
|
-
'',
|
441
|
-
" #{STEP_KEYWORD} a step",
|
442
|
-
' | value |',
|
443
|
-
" #{STEP_KEYWORD} another step",
|
444
|
-
' """',
|
445
|
-
' some string',
|
446
|
-
' """'])
|
447
|
-
end
|
448
|
-
|
449
|
-
end
|
450
|
-
|
451
|
-
|
452
|
-
context 'from abstract instantiation' do
|
453
|
-
|
454
|
-
let(:scenario) { clazz.new }
|
455
|
-
|
456
|
-
|
457
|
-
it 'can output a scenario that has only tags' do
|
458
|
-
scenario.tags = [CukeModeler::Tag.new]
|
459
|
-
|
460
|
-
expect { scenario.to_s }.to_not raise_error
|
461
|
-
end
|
462
|
-
|
463
|
-
it 'can output a scenario that has only steps' do
|
464
|
-
scenario.steps = [CukeModeler::Step.new]
|
465
|
-
|
466
|
-
expect { scenario.to_s }.to_not raise_error
|
467
|
-
end
|
468
|
-
|
469
|
-
end
|
470
|
-
|
471
|
-
end
|
472
|
-
|
473
|
-
end
|
474
|
-
|
475
|
-
end
|