cuke_modeler 1.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +329 -0
- data/LICENSE.txt +1 -1
- data/README.md +25 -18
- data/cuke_modeler.gemspec +15 -9
- data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +75 -64
- data/lib/cuke_modeler/containing.rb +16 -0
- data/lib/cuke_modeler/described.rb +1 -0
- data/lib/cuke_modeler/models/background.rb +1 -1
- data/lib/cuke_modeler/models/cell.rb +1 -1
- data/lib/cuke_modeler/models/comment.rb +1 -1
- data/lib/cuke_modeler/models/directory.rb +2 -2
- data/lib/cuke_modeler/models/doc_string.rb +1 -1
- data/lib/cuke_modeler/models/example.rb +1 -1
- data/lib/cuke_modeler/models/feature.rb +1 -1
- data/lib/cuke_modeler/models/feature_file.rb +2 -2
- data/lib/cuke_modeler/models/outline.rb +1 -1
- data/lib/cuke_modeler/models/row.rb +1 -1
- data/lib/cuke_modeler/models/scenario.rb +1 -1
- data/lib/cuke_modeler/models/step.rb +32 -3
- data/lib/cuke_modeler/models/table.rb +1 -1
- data/lib/cuke_modeler/models/tag.rb +1 -1
- data/lib/cuke_modeler/named.rb +1 -0
- data/lib/cuke_modeler/nested.rb +1 -0
- data/lib/cuke_modeler/parsed.rb +1 -0
- data/lib/cuke_modeler/parsing.rb +88 -92
- data/lib/cuke_modeler/sourceable.rb +1 -0
- data/lib/cuke_modeler/stepped.rb +1 -0
- data/lib/cuke_modeler/taggable.rb +1 -0
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/analysis/step_comparison.feature +25 -0
- data/testing/cucumber/features/analysis/test_comparison.feature +1 -1
- metadata +55 -142
- data/.gitignore +0 -18
- data/.simplecov +0 -7
- data/.travis.yml +0 -54
- data/Gemfile +0 -36
- data/History.md +0 -191
- data/Rakefile +0 -63
- data/appveyor.yml +0 -43
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -273
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -296
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -308
- 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 -44
- 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 -173
- 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 -32
- data/testing/gemfiles/gherkin3.gemfile +0 -26
- data/testing/gemfiles/gherkin4.gemfile +0 -27
- data/testing/gemfiles/gherkin5.gemfile +0 -26
- data/testing/gemfiles/gherkin6.gemfile +0 -10
- data/testing/rspec/spec/integration/background_integration_spec.rb +0 -442
- data/testing/rspec/spec/integration/cell_integration_spec.rb +0 -335
- data/testing/rspec/spec/integration/comment_integration_spec.rb +0 -177
- data/testing/rspec/spec/integration/directory_integration_spec.rb +0 -218
- data/testing/rspec/spec/integration/doc_string_integration_spec.rb +0 -402
- data/testing/rspec/spec/integration/example_integration_spec.rb +0 -741
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +0 -272
- data/testing/rspec/spec/integration/feature_integration_spec.rb +0 -650
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +0 -165
- data/testing/rspec/spec/integration/gherkin_6_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/model_integration_spec.rb +0 -15
- data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
- data/testing/rspec/spec/integration/outline_integration_spec.rb +0 -624
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -117
- data/testing/rspec/spec/integration/row_integration_spec.rb +0 -291
- data/testing/rspec/spec/integration/scenario_integration_spec.rb +0 -479
- data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
- data/testing/rspec/spec/integration/step_integration_spec.rb +0 -475
- data/testing/rspec/spec/integration/table_integration_spec.rb +0 -337
- data/testing/rspec/spec/integration/tag_integration_spec.rb +0 -259
- data/testing/rspec/spec/spec_helper.rb +0 -122
- data/testing/rspec/spec/unit/background_unit_spec.rb +0 -83
- data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -127
- data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -100
- data/testing/rspec/spec/unit/example_unit_spec.rb +0 -133
- data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -157
- data/testing/rspec/spec/unit/model_unit_spec.rb +0 -15
- 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/outline_unit_spec.rb +0 -117
- 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/row_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -86
- 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 -25
- 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/step_unit_spec.rb +0 -109
- data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/table_unit_spec.rb +0 -77
- data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
- data/testing/test_languages.json +0 -45
- data/todo.txt +0 -24
@@ -1,18 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
2
|
-
|
3
|
-
shared_examples_for 'a model, integration' do
|
4
|
-
|
5
|
-
# clazz must be defined by the calling file
|
6
|
-
|
7
|
-
let(:model) { clazz.new }
|
8
|
-
|
9
|
-
|
10
|
-
describe 'unique behavior' do
|
11
|
-
|
12
|
-
it 'inherits from the common model class' do
|
13
|
-
expect(model).to be_a(CukeModeler::Model)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,475 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Step, Integration' do
|
5
|
-
|
6
|
-
let(:clazz) { CukeModeler::Step }
|
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 = "#{STEP_KEYWORD} a step"
|
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 = "Y'know a step"
|
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.keyword).to eq("Y'know")
|
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 step text\n And a step\n @foo"
|
42
|
-
|
43
|
-
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_step\.feature'/)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'stores the original data generated by the parsing adapter (with a table)', :gherkin6 => true do
|
47
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
|
48
|
-
data = step.parsing_data
|
49
|
-
|
50
|
-
expect(data.keys).to match_array([:location, :keyword, :text, :data_table, :doc_string])
|
51
|
-
expect(data[:text]).to eq('test step')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin6 => true do
|
55
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
|
56
|
-
data = step.parsing_data
|
57
|
-
|
58
|
-
expect(data.keys).to match_array([:location, :keyword, :text, :data_table, :doc_string])
|
59
|
-
expect(data[:text]).to eq('test step')
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'stores the original data generated by the parsing adapter (with a table)', :gherkin4_5 => true do
|
63
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
|
64
|
-
data = step.parsing_data
|
65
|
-
|
66
|
-
expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
|
67
|
-
expect(data[:type]).to eq(:Step)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin4_5 => true do
|
71
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
|
72
|
-
data = step.parsing_data
|
73
|
-
|
74
|
-
expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
|
75
|
-
expect(data[:type]).to eq(:Step)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'stores the original data generated by the parsing adapter (with a table)', :gherkin3 => true do
|
79
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
|
80
|
-
data = step.parsing_data
|
81
|
-
|
82
|
-
expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
|
83
|
-
expect(data[:type]).to eq(:Step)
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin3 => true do
|
87
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
|
88
|
-
data = step.parsing_data
|
89
|
-
|
90
|
-
expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
|
91
|
-
expect(data[:type]).to eq(:Step)
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'stores the original data generated by the parsing adapter (with a table)', :gherkin2 => true do
|
95
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
|
96
|
-
data = step.parsing_data
|
97
|
-
|
98
|
-
expect(data.keys).to match_array(['keyword', 'name', 'line', 'rows'])
|
99
|
-
expect(data['keyword']).to eq("#{STEP_KEYWORD} ")
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin2 => true do
|
103
|
-
step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
|
104
|
-
data = step.parsing_data
|
105
|
-
|
106
|
-
expect(data.keys).to match_array(['keyword', 'name', 'line', 'doc_string'])
|
107
|
-
expect(data['keyword']).to eq("#{STEP_KEYWORD} ")
|
108
|
-
end
|
109
|
-
|
110
|
-
describe 'model population' do
|
111
|
-
|
112
|
-
context 'from source text' do
|
113
|
-
|
114
|
-
let(:source_text) { "#{STEP_KEYWORD} a step" }
|
115
|
-
let(:step) { clazz.new(source_text) }
|
116
|
-
|
117
|
-
|
118
|
-
it "models the step's keyword" do
|
119
|
-
expect(step.keyword).to eq("#{STEP_KEYWORD}")
|
120
|
-
end
|
121
|
-
|
122
|
-
it "models the step's text" do
|
123
|
-
expect(step.text).to eq('a step')
|
124
|
-
end
|
125
|
-
|
126
|
-
it "models the step's source line" do
|
127
|
-
source_text = "#{FEATURE_KEYWORD}:
|
128
|
-
|
129
|
-
#{SCENARIO_KEYWORD}: foo
|
130
|
-
#{STEP_KEYWORD} step"
|
131
|
-
step = CukeModeler::Feature.new(source_text).tests.first.steps.first
|
132
|
-
|
133
|
-
expect(step.source_line).to eq(4)
|
134
|
-
end
|
135
|
-
|
136
|
-
|
137
|
-
context 'with no block' do
|
138
|
-
|
139
|
-
let(:source_text) { "#{STEP_KEYWORD} a step" }
|
140
|
-
let(:step) { clazz.new(source_text) }
|
141
|
-
|
142
|
-
|
143
|
-
it "models the step's block" do
|
144
|
-
expect(step.block).to be_nil
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'a step with a table' do
|
150
|
-
|
151
|
-
let(:source_text) { "#{STEP_KEYWORD} a step
|
152
|
-
| value 1 |
|
153
|
-
| value 2 |" }
|
154
|
-
let(:step) { clazz.new(source_text) }
|
155
|
-
|
156
|
-
|
157
|
-
it "models the step's table" do
|
158
|
-
table_cell_values = step.block.rows.collect { |row| row.cells.collect { |cell| cell.value } }
|
159
|
-
|
160
|
-
expect(table_cell_values).to eq([['value 1'], ['value 2']])
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
context 'a step with a doc string' do
|
166
|
-
|
167
|
-
let(:source_text) { "#{STEP_KEYWORD} a step
|
168
|
-
\"\"\"
|
169
|
-
some text
|
170
|
-
\"\"\"" }
|
171
|
-
let(:step) { clazz.new(source_text) }
|
172
|
-
|
173
|
-
|
174
|
-
it "models the step's doc string" do
|
175
|
-
doc_string = step.block
|
176
|
-
|
177
|
-
expect(doc_string.content).to eq('some text')
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
|
187
|
-
it 'properly sets its child models' do
|
188
|
-
source_1 = "#{STEP_KEYWORD} a step
|
189
|
-
\"\"\"
|
190
|
-
a doc string
|
191
|
-
\"\"\""
|
192
|
-
source_2 = "#{STEP_KEYWORD} a step
|
193
|
-
| a block|"
|
194
|
-
|
195
|
-
step_1 = clazz.new(source_1)
|
196
|
-
step_2 = clazz.new(source_2)
|
197
|
-
|
198
|
-
|
199
|
-
doc_string = step_1.block
|
200
|
-
table = step_2.block
|
201
|
-
|
202
|
-
expect(doc_string.parent_model).to equal(step_1)
|
203
|
-
expect(table.parent_model).to equal(step_2)
|
204
|
-
end
|
205
|
-
|
206
|
-
|
207
|
-
describe 'step comparison' do
|
208
|
-
|
209
|
-
it 'is equal to another Step that has the same text' do
|
210
|
-
source_1 = "#{STEP_KEYWORD} a step"
|
211
|
-
source_2 = "#{STEP_KEYWORD} a step"
|
212
|
-
source_3 = "#{STEP_KEYWORD} a different step"
|
213
|
-
|
214
|
-
step_1 = clazz.new(source_1)
|
215
|
-
step_2 = clazz.new(source_2)
|
216
|
-
step_3 = clazz.new(source_3)
|
217
|
-
|
218
|
-
|
219
|
-
expect(step_1).to eq(step_2)
|
220
|
-
expect(step_1).to_not eq(step_3)
|
221
|
-
end
|
222
|
-
|
223
|
-
it 'ignores steps keywords when comparing steps' do
|
224
|
-
source_1 = "#{GIVEN_KEYWORD} a step"
|
225
|
-
source_2 = "#{THEN_KEYWORD} a step"
|
226
|
-
|
227
|
-
step_1 = clazz.new(source_1)
|
228
|
-
step_2 = clazz.new(source_2)
|
229
|
-
|
230
|
-
|
231
|
-
expect(step_1).to eq(step_2)
|
232
|
-
end
|
233
|
-
|
234
|
-
it 'ignores step tables when comparing steps' do
|
235
|
-
source_1 = "#{STEP_KEYWORD} a step"
|
236
|
-
source_2 = "#{STEP_KEYWORD} a step\n|with a table|"
|
237
|
-
|
238
|
-
step_1 = clazz.new(source_1)
|
239
|
-
step_2 = clazz.new(source_2)
|
240
|
-
|
241
|
-
|
242
|
-
expect(step_1).to eq(step_2)
|
243
|
-
end
|
244
|
-
|
245
|
-
it 'ignores step doc strings when comparing steps' do
|
246
|
-
source_1 = "#{STEP_KEYWORD} a step"
|
247
|
-
source_2 = "#{STEP_KEYWORD} a step\n\"\"\"\nwith a doc string\n\"\"\""
|
248
|
-
|
249
|
-
|
250
|
-
step_1 = clazz.new(source_1)
|
251
|
-
step_2 = clazz.new(source_2)
|
252
|
-
|
253
|
-
|
254
|
-
expect(step_1).to eq(step_2)
|
255
|
-
end
|
256
|
-
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
describe 'getting ancestors' do
|
261
|
-
|
262
|
-
before(:each) do
|
263
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'step_test_file', :directory => test_directory)
|
264
|
-
end
|
265
|
-
|
266
|
-
|
267
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
268
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
269
|
-
|
270
|
-
#{SCENARIO_KEYWORD}: Test test
|
271
|
-
#{STEP_KEYWORD} a step:"
|
272
|
-
}
|
273
|
-
|
274
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
275
|
-
let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
|
276
|
-
|
277
|
-
|
278
|
-
it 'can get its directory' do
|
279
|
-
ancestor = step_model.get_ancestor(:directory)
|
280
|
-
|
281
|
-
expect(ancestor).to equal(directory_model)
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'can get its feature file' do
|
285
|
-
ancestor = step_model.get_ancestor(:feature_file)
|
286
|
-
|
287
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
288
|
-
end
|
289
|
-
|
290
|
-
it 'can get its feature' do
|
291
|
-
ancestor = step_model.get_ancestor(:feature)
|
292
|
-
|
293
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
294
|
-
end
|
295
|
-
|
296
|
-
|
297
|
-
context 'a step that is part of a scenario' do
|
298
|
-
|
299
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
300
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
301
|
-
|
302
|
-
#{SCENARIO_KEYWORD}: Test scenario
|
303
|
-
#{STEP_KEYWORD} a step"
|
304
|
-
}
|
305
|
-
|
306
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
307
|
-
let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
|
308
|
-
|
309
|
-
|
310
|
-
it 'can get its scenario' do
|
311
|
-
ancestor = step_model.get_ancestor(:scenario)
|
312
|
-
|
313
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
314
|
-
end
|
315
|
-
|
316
|
-
end
|
317
|
-
|
318
|
-
context 'a step that is part of an outline' do
|
319
|
-
|
320
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
321
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
322
|
-
|
323
|
-
#{OUTLINE_KEYWORD}: Test outline
|
324
|
-
#{STEP_KEYWORD} a step
|
325
|
-
#{EXAMPLE_KEYWORD}:
|
326
|
-
| param |
|
327
|
-
| value |"
|
328
|
-
}
|
329
|
-
|
330
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
331
|
-
let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
|
332
|
-
|
333
|
-
|
334
|
-
it 'can get its outline' do
|
335
|
-
ancestor = step_model.get_ancestor(:outline)
|
336
|
-
|
337
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
338
|
-
end
|
339
|
-
|
340
|
-
end
|
341
|
-
|
342
|
-
context 'a step that is part of a background' do
|
343
|
-
|
344
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
345
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
346
|
-
|
347
|
-
#{BACKGROUND_KEYWORD}: Test background
|
348
|
-
#{STEP_KEYWORD} a step"
|
349
|
-
}
|
350
|
-
|
351
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
352
|
-
let(:step_model) { directory_model.feature_files.first.feature.background.steps.first }
|
353
|
-
|
354
|
-
|
355
|
-
it 'can get its background' do
|
356
|
-
ancestor = step_model.get_ancestor(:background)
|
357
|
-
|
358
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
|
359
|
-
end
|
360
|
-
|
361
|
-
end
|
362
|
-
|
363
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
364
|
-
ancestor = step_model.get_ancestor(:example)
|
365
|
-
|
366
|
-
expect(ancestor).to be_nil
|
367
|
-
end
|
368
|
-
|
369
|
-
end
|
370
|
-
|
371
|
-
|
372
|
-
describe 'step output' do
|
373
|
-
|
374
|
-
context 'from source text' do
|
375
|
-
|
376
|
-
context 'with no block' do
|
377
|
-
|
378
|
-
let(:source_text) { ["#{STEP_KEYWORD} a step"].join("\n") }
|
379
|
-
let(:step) { clazz.new(source_text) }
|
380
|
-
|
381
|
-
it 'can output a step' do
|
382
|
-
step_output = step.to_s.split("\n", -1)
|
383
|
-
|
384
|
-
expect(step_output).to eq(["#{STEP_KEYWORD} a step"])
|
385
|
-
end
|
386
|
-
|
387
|
-
it 'can be remade from its own output' do
|
388
|
-
step_output = step.to_s
|
389
|
-
remade_step_output = clazz.new(step_output).to_s
|
390
|
-
|
391
|
-
expect(remade_step_output).to eq(step_output)
|
392
|
-
end
|
393
|
-
|
394
|
-
end
|
395
|
-
|
396
|
-
context 'a step with a table' do
|
397
|
-
|
398
|
-
let(:source_text) { ["#{STEP_KEYWORD} a step",
|
399
|
-
' | value1 | value2 |',
|
400
|
-
' | value3 | value4 |'].join("\n") }
|
401
|
-
let(:step) { clazz.new(source_text) }
|
402
|
-
|
403
|
-
|
404
|
-
it 'can output a step that has a table' do
|
405
|
-
step_output = step.to_s.split("\n", -1)
|
406
|
-
|
407
|
-
expect(step_output).to eq(["#{STEP_KEYWORD} a step",
|
408
|
-
' | value1 | value2 |',
|
409
|
-
' | value3 | value4 |'])
|
410
|
-
|
411
|
-
end
|
412
|
-
|
413
|
-
it 'can be remade from its own output' do
|
414
|
-
step_output = step.to_s
|
415
|
-
remade_step_output = clazz.new(step_output).to_s
|
416
|
-
|
417
|
-
expect(remade_step_output).to eq(step_output)
|
418
|
-
end
|
419
|
-
|
420
|
-
end
|
421
|
-
|
422
|
-
context 'a step with a doc string' do
|
423
|
-
|
424
|
-
let(:source_text) { ["#{STEP_KEYWORD} a step",
|
425
|
-
' """',
|
426
|
-
' some text',
|
427
|
-
' """'].join("\n") }
|
428
|
-
let(:step) { clazz.new(source_text) }
|
429
|
-
|
430
|
-
|
431
|
-
it 'can output a step that has a doc string' do
|
432
|
-
step_output = step.to_s.split("\n", -1)
|
433
|
-
|
434
|
-
expect(step_output).to eq(["#{STEP_KEYWORD} a step",
|
435
|
-
' """',
|
436
|
-
' some text',
|
437
|
-
' """'])
|
438
|
-
end
|
439
|
-
|
440
|
-
it 'can be remade from its own output' do
|
441
|
-
step_output = step.to_s
|
442
|
-
remade_step_output = clazz.new(step_output).to_s
|
443
|
-
|
444
|
-
expect(remade_step_output).to eq(step_output)
|
445
|
-
end
|
446
|
-
|
447
|
-
end
|
448
|
-
|
449
|
-
end
|
450
|
-
|
451
|
-
|
452
|
-
context 'from abstract instantiation' do
|
453
|
-
|
454
|
-
let(:step) { clazz.new }
|
455
|
-
|
456
|
-
|
457
|
-
it 'can output a step that has only a table' do
|
458
|
-
step.block = CukeModeler::Table.new
|
459
|
-
|
460
|
-
expect { step.to_s }.to_not raise_error
|
461
|
-
end
|
462
|
-
|
463
|
-
it 'can output a step that has only a doc string' do
|
464
|
-
step.block = CukeModeler::DocString.new
|
465
|
-
|
466
|
-
expect { step.to_s }.to_not raise_error
|
467
|
-
end
|
468
|
-
|
469
|
-
end
|
470
|
-
|
471
|
-
end
|
472
|
-
|
473
|
-
end
|
474
|
-
|
475
|
-
end
|