cuke_modeler 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +12 -0
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +5 -5
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +8 -5
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +8 -5
- data/lib/cuke_modeler/containing.rb +12 -7
- data/lib/cuke_modeler/models/background.rb +7 -2
- data/lib/cuke_modeler/models/cell.rb +2 -1
- data/lib/cuke_modeler/models/doc_string.rb +2 -1
- data/lib/cuke_modeler/models/example.rb +8 -4
- data/lib/cuke_modeler/models/feature.rb +4 -1
- data/lib/cuke_modeler/models/outline.rb +6 -2
- data/lib/cuke_modeler/models/row.rb +2 -1
- data/lib/cuke_modeler/models/scenario.rb +7 -2
- data/lib/cuke_modeler/models/step.rb +2 -1
- data/lib/cuke_modeler/models/table.rb +2 -1
- data/lib/cuke_modeler/models/tag.rb +2 -1
- data/lib/cuke_modeler/parsing.rb +45 -0
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/modeling/background_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/background_output.feature +6 -1
- data/testing/cucumber/features/modeling/directory_output.feature +6 -1
- data/testing/cucumber/features/modeling/doc_string_output.feature +6 -1
- data/testing/cucumber/features/modeling/example_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/example_output.feature +6 -1
- data/testing/cucumber/features/modeling/feature_file_output.feature +6 -1
- data/testing/cucumber/features/modeling/feature_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/feature_output.feature +6 -1
- data/testing/cucumber/features/modeling/model_output.feature +1 -8
- data/testing/cucumber/features/modeling/outline_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/outline_output.feature +6 -1
- data/testing/cucumber/features/modeling/row_output.feature +6 -1
- data/testing/cucumber/features/modeling/scenario_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/scenario_output.feature +6 -1
- data/testing/cucumber/features/modeling/step_output.feature +6 -1
- data/testing/cucumber/features/modeling/table_output.feature +6 -1
- data/testing/cucumber/features/modeling/tag_output.feature +6 -1
- data/testing/cucumber/step_definitions/verification_steps.rb +21 -12
- data/testing/dialect_helper.rb +48 -0
- data/testing/rspec/spec/integration/background_integration_spec.rb +93 -88
- data/testing/rspec/spec/integration/cell_integration_spec.rb +26 -27
- data/testing/rspec/spec/integration/directory_integration_spec.rb +4 -4
- data/testing/rspec/spec/integration/doc_string_integration_spec.rb +38 -39
- data/testing/rspec/spec/integration/example_integration_spec.rb +97 -95
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +5 -5
- data/testing/rspec/spec/integration/feature_integration_spec.rb +157 -155
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +17 -17
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +17 -17
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +17 -17
- data/testing/rspec/spec/integration/outline_integration_spec.rb +359 -354
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +30 -2
- data/testing/rspec/spec/integration/row_integration_spec.rb +23 -25
- data/testing/rspec/spec/integration/scenario_integration_spec.rb +238 -235
- data/testing/rspec/spec/integration/step_integration_spec.rb +69 -64
- data/testing/rspec/spec/integration/table_integration_spec.rb +32 -36
- data/testing/rspec/spec/integration/tag_integration_spec.rb +26 -27
- data/testing/rspec/spec/spec_helper.rb +43 -0
- data/testing/rspec/spec/unit/background_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/example_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/feature_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/outline_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/parsing_unit_spec.rb +33 -0
- data/testing/rspec/spec/unit/scenario_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +58 -0
- data/testing/rspec/spec/unit/step_unit_spec.rb +1 -23
- data/testing/test_languages.json +45 -0
- data/todo.txt +1 -1
- metadata +6 -3
@@ -8,10 +8,38 @@ describe 'Parsing, Integration' do
|
|
8
8
|
|
9
9
|
describe 'unique behavior' do
|
10
10
|
|
11
|
+
it 'loads the correct dialects based on the version of Gherkin used', :gherkin3 => true, :gherkin4 => true do
|
12
|
+
expect(nodule.dialects).to equal(Gherkin::DIALECTS)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'loads the correct dialects based on the version of Gherkin used', :gherkin2 => true do
|
16
|
+
expect(nodule.dialects).to equal(Gherkin::I18n::LANGUAGES)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'can parse text that uses a non-default dialect' do
|
20
|
+
source_text = "# language: en-au
|
21
|
+
Pretty much:
|
22
|
+
|
23
|
+
First off:
|
24
|
+
Y'know foo
|
25
|
+
|
26
|
+
Awww, look mate:
|
27
|
+
It's just unbelievable that zip
|
28
|
+
But at the end of the day I reckon bar
|
29
|
+
|
30
|
+
Reckon it's like:
|
31
|
+
Yeah nah zen
|
32
|
+
Too right baz
|
33
|
+
You'll wanna:
|
34
|
+
| param |
|
35
|
+
| value |"
|
36
|
+
|
37
|
+
expect { nodule.parse_text(source_text) }.to_not raise_error
|
38
|
+
end
|
11
39
|
|
12
40
|
it 'raises and error if given something to parse besides a string' do
|
13
41
|
expect { nodule.parse_text(5) }.to raise_error(ArgumentError, /Text to parse must be a String but got/)
|
14
|
-
expect { nodule.parse_text(
|
42
|
+
expect { nodule.parse_text("#{@feature_keyword}:") }.to_not raise_error
|
15
43
|
end
|
16
44
|
|
17
45
|
it 'includes the type of object provided when raising an non-string exception' do
|
@@ -19,7 +47,7 @@ describe 'Parsing, Integration' do
|
|
19
47
|
end
|
20
48
|
|
21
49
|
it 'returns an Array' do
|
22
|
-
result = nodule.parse_text(
|
50
|
+
result = nodule.parse_text("#{@feature_keyword}:")
|
23
51
|
expect(result).to be_a(Array)
|
24
52
|
end
|
25
53
|
|
@@ -66,12 +66,11 @@ describe 'Row, Integration' do
|
|
66
66
|
describe 'getting ancestors' do
|
67
67
|
|
68
68
|
before(:each) do
|
69
|
-
source =
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
source = source.join("\n")
|
69
|
+
source = "#{@feature_keyword}: Test feature
|
70
|
+
|
71
|
+
#{@scenario_keyword}: Test test
|
72
|
+
#{@step_keyword} a step:
|
73
|
+
| a | table |"
|
75
74
|
|
76
75
|
file_path = "#{@default_file_directory}/row_test_file.feature"
|
77
76
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -114,11 +113,11 @@ describe 'Row, Integration' do
|
|
114
113
|
context 'a row that is part of a scenario' do
|
115
114
|
|
116
115
|
before(:each) do
|
117
|
-
source =
|
116
|
+
source = "#{@feature_keyword}: Test feature
|
118
117
|
|
119
|
-
|
120
|
-
|
121
|
-
| a | table |
|
118
|
+
#{@scenario_keyword}: Test test
|
119
|
+
#{@step_keyword} a step:
|
120
|
+
| a | table |"
|
122
121
|
|
123
122
|
file_path = "#{@default_file_directory}/row_test_file.feature"
|
124
123
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -140,11 +139,11 @@ describe 'Row, Integration' do
|
|
140
139
|
context 'a row that is part of a background' do
|
141
140
|
|
142
141
|
before(:each) do
|
143
|
-
source =
|
142
|
+
source = "#{@feature_keyword}: Test feature
|
144
143
|
|
145
|
-
|
146
|
-
|
147
|
-
| a | table |
|
144
|
+
#{@background_keyword}: Test background
|
145
|
+
#{@step_keyword} a step:
|
146
|
+
| a | table |"
|
148
147
|
|
149
148
|
file_path = "#{@default_file_directory}/row_test_file.feature"
|
150
149
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -165,13 +164,13 @@ describe 'Row, Integration' do
|
|
165
164
|
context 'a row that is part of an outline' do
|
166
165
|
|
167
166
|
before(:each) do
|
168
|
-
source =
|
167
|
+
source = "#{@feature_keyword}: Test feature
|
169
168
|
|
170
|
-
|
171
|
-
|
172
|
-
|
169
|
+
#{@outline_keyword}: Test outline
|
170
|
+
#{@step_keyword} a step
|
171
|
+
#{@example_keyword}:
|
173
172
|
| param |
|
174
|
-
| value |
|
173
|
+
| value |"
|
175
174
|
|
176
175
|
file_path = "#{@default_file_directory}/row_test_file.feature"
|
177
176
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -219,11 +218,11 @@ describe 'Row, Integration' do
|
|
219
218
|
end
|
220
219
|
|
221
220
|
it "models the row's source line" do
|
222
|
-
source_text = "
|
221
|
+
source_text = "#{@feature_keyword}: Test feature
|
223
222
|
|
224
|
-
|
225
|
-
|
226
|
-
|
223
|
+
#{@outline_keyword}: Test outline
|
224
|
+
#{@step_keyword} a step
|
225
|
+
#{@example_keyword}:
|
227
226
|
| param |
|
228
227
|
| value |"
|
229
228
|
row = CukeModeler::Feature.new(source_text).tests.first.examples.first.rows.first
|
@@ -239,8 +238,7 @@ describe 'Row, Integration' do
|
|
239
238
|
describe 'row output' do
|
240
239
|
|
241
240
|
it 'can be remade from its own output' do
|
242
|
-
source =
|
243
|
-
source = source.join("\n")
|
241
|
+
source = "| value1 | value2 |"
|
244
242
|
row = clazz.new(source)
|
245
243
|
|
246
244
|
row_output = row.to_s
|
@@ -15,19 +15,19 @@ describe 'Scenario, Integration' do
|
|
15
15
|
describe 'unique behavior' do
|
16
16
|
|
17
17
|
it 'can be instantiated with the minimum viable Gherkin' do
|
18
|
-
source =
|
18
|
+
source = "#{@scenario_keyword}:"
|
19
19
|
|
20
20
|
expect { clazz.new(source) }.to_not raise_error
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'provides a descriptive filename when being parsed from stand alone text' do
|
24
|
-
source = "bad scenario text \n
|
24
|
+
source = "bad scenario text \n #{@scenario_keyword}:\n And a step\n @foo "
|
25
25
|
|
26
26
|
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_scenario\.feature'/)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
|
30
|
-
scenario = clazz.new("@tag\
|
30
|
+
scenario = clazz.new("@tag\n#{@scenario_keyword}: test scenario\ndescription\n#{@step_keyword} a step")
|
31
31
|
data = scenario.parsing_data
|
32
32
|
|
33
33
|
expect(data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps, :description])
|
@@ -35,7 +35,7 @@ describe 'Scenario, Integration' do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
38
|
-
scenario = clazz.new("@tag\
|
38
|
+
scenario = clazz.new("@tag\n#{@scenario_keyword}: test scenario\ndescription\n#{@step_keyword} a step")
|
39
39
|
data = scenario.parsing_data
|
40
40
|
|
41
41
|
expect(data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps, :description])
|
@@ -43,7 +43,7 @@ describe 'Scenario, Integration' do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
46
|
-
scenario = clazz.new("@tag\
|
46
|
+
scenario = clazz.new("@tag\n#{@scenario_keyword}: test scenario\ndescription\n#{@step_keyword} a step")
|
47
47
|
data = scenario.parsing_data
|
48
48
|
|
49
49
|
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'type', 'steps', 'tags'])
|
@@ -51,10 +51,9 @@ describe 'Scenario, Integration' do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'properly sets its child models' do
|
54
|
-
source =
|
55
|
-
|
56
|
-
|
57
|
-
source = source.join("\n")
|
54
|
+
source = "@a_tag
|
55
|
+
#{@scenario_keyword}: Test scenario
|
56
|
+
#{@step_keyword} a step"
|
58
57
|
|
59
58
|
scenario = clazz.new(source)
|
60
59
|
step = scenario.steps.first
|
@@ -65,7 +64,7 @@ describe 'Scenario, Integration' do
|
|
65
64
|
end
|
66
65
|
|
67
66
|
it 'trims whitespace from its source description' do
|
68
|
-
source = [
|
67
|
+
source = ["#{@scenario_keyword}:",
|
69
68
|
' ',
|
70
69
|
' description line 1',
|
71
70
|
'',
|
@@ -74,11 +73,11 @@ describe 'Scenario, Integration' do
|
|
74
73
|
'',
|
75
74
|
'',
|
76
75
|
'',
|
77
|
-
|
76
|
+
" #{@step_keyword} a step"]
|
78
77
|
source = source.join("\n")
|
79
78
|
|
80
79
|
scenario = clazz.new(source)
|
81
|
-
description = scenario.description.split("\n")
|
80
|
+
description = scenario.description.split("\n", -1)
|
82
81
|
|
83
82
|
expect(description).to eq([' description line 1',
|
84
83
|
'',
|
@@ -90,11 +89,10 @@ describe 'Scenario, Integration' do
|
|
90
89
|
describe 'getting ancestors' do
|
91
90
|
|
92
91
|
before(:each) do
|
93
|
-
source =
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
source = source.join("\n")
|
92
|
+
source = "#{@feature_keyword}: Test feature
|
93
|
+
|
94
|
+
#{@scenario_keyword}: Test test
|
95
|
+
#{@step_keyword} a step"
|
98
96
|
|
99
97
|
file_path = "#{@default_file_directory}/scenario_test_file.feature"
|
100
98
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -128,314 +126,321 @@ describe 'Scenario, Integration' do
|
|
128
126
|
expect(ancestor).to be_nil
|
129
127
|
end
|
130
128
|
|
129
|
+
end
|
131
130
|
|
132
|
-
describe 'model population' do
|
133
131
|
|
134
|
-
|
132
|
+
describe 'model population' do
|
135
133
|
|
136
|
-
|
137
|
-
source_text = "Feature:
|
134
|
+
context 'from source text' do
|
138
135
|
|
139
|
-
|
140
|
-
|
141
|
-
scenario = CukeModeler::Feature.new(source_text).tests.first
|
136
|
+
let(:source_text) { "#{@scenario_keyword}:" }
|
137
|
+
let(:scenario) { clazz.new(source_text) }
|
142
138
|
|
143
|
-
|
144
|
-
|
139
|
+
|
140
|
+
it "models the scenario's keyword" do
|
141
|
+
expect(scenario.keyword).to eq("#{@scenario_keyword}")
|
142
|
+
end
|
143
|
+
|
144
|
+
it "models the scenario's source line" do
|
145
|
+
source_text = "#{@feature_keyword}:
|
146
|
+
|
147
|
+
#{@scenario_keyword}: foo
|
148
|
+
#{@step_keyword} step"
|
149
|
+
scenario = CukeModeler::Feature.new(source_text).tests.first
|
150
|
+
|
151
|
+
expect(scenario.source_line).to eq(3)
|
152
|
+
end
|
145
153
|
|
146
154
|
|
147
|
-
|
155
|
+
context 'a filled scenario' do
|
148
156
|
|
149
|
-
|
150
|
-
|
157
|
+
let(:source_text) { "@tag1 @tag2 @tag3
|
158
|
+
#{@scenario_keyword}: Scenario name
|
151
159
|
|
152
160
|
Scenario description.
|
153
161
|
|
154
162
|
Some more.
|
155
163
|
Even more.
|
156
164
|
|
157
|
-
|
158
|
-
|
159
|
-
|
165
|
+
#{@step_keyword} a step
|
166
|
+
#{@step_keyword} another step" }
|
167
|
+
let(:scenario) { clazz.new(source_text) }
|
160
168
|
|
161
169
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
it "models the scenario's description" do
|
167
|
-
description = scenario.description.split("\n")
|
170
|
+
it "models the scenario's name" do
|
171
|
+
expect(scenario.name).to eq('Scenario name')
|
172
|
+
end
|
168
173
|
|
169
|
-
|
170
|
-
|
171
|
-
'Some more.',
|
172
|
-
' Even more.'])
|
173
|
-
end
|
174
|
+
it "models the scenario's description" do
|
175
|
+
description = scenario.description.split("\n", -1)
|
174
176
|
|
175
|
-
|
176
|
-
|
177
|
+
expect(description).to eq([' Scenario description.',
|
178
|
+
'',
|
179
|
+
'Some more.',
|
180
|
+
' Even more.'])
|
181
|
+
end
|
177
182
|
|
178
|
-
|
179
|
-
|
183
|
+
it "models the scenario's steps" do
|
184
|
+
step_names = scenario.steps.collect { |step| step.text }
|
180
185
|
|
181
|
-
|
182
|
-
|
186
|
+
expect(step_names).to eq(['a step', 'another step'])
|
187
|
+
end
|
183
188
|
|
184
|
-
|
185
|
-
|
189
|
+
it "models the scenario's tags" do
|
190
|
+
tag_names = scenario.tags.collect { |tag| tag.name }
|
186
191
|
|
192
|
+
expect(tag_names).to eq(['@tag1', '@tag2', '@tag3'])
|
187
193
|
end
|
188
194
|
|
189
|
-
|
195
|
+
end
|
190
196
|
|
191
|
-
|
192
|
-
let(:scenario) { clazz.new(source_text) }
|
197
|
+
context 'an empty scenario' do
|
193
198
|
|
199
|
+
let(:source_text) { "#{@scenario_keyword}:" }
|
200
|
+
let(:scenario) { clazz.new(source_text) }
|
194
201
|
|
195
|
-
it "models the scenario's name" do
|
196
|
-
expect(scenario.name).to eq('')
|
197
|
-
end
|
198
202
|
|
199
|
-
|
200
|
-
|
201
|
-
|
203
|
+
it "models the scenario's name" do
|
204
|
+
expect(scenario.name).to eq('')
|
205
|
+
end
|
202
206
|
|
203
|
-
|
204
|
-
|
205
|
-
|
207
|
+
it "models the scenario's description" do
|
208
|
+
expect(scenario.description).to eq('')
|
209
|
+
end
|
206
210
|
|
207
|
-
|
208
|
-
|
209
|
-
|
211
|
+
it "models the scenario's steps" do
|
212
|
+
expect(scenario.steps).to eq([])
|
213
|
+
end
|
210
214
|
|
215
|
+
it "models the scenario's tags" do
|
216
|
+
expect(scenario.tags).to eq([])
|
211
217
|
end
|
212
218
|
|
213
219
|
end
|
214
220
|
|
215
221
|
end
|
216
222
|
|
223
|
+
end
|
217
224
|
|
218
|
-
describe 'comparison' do
|
219
225
|
|
220
|
-
|
221
|
-
source = "Scenario:
|
222
|
-
* step 1
|
223
|
-
* step 2"
|
224
|
-
scenario = clazz.new(source)
|
226
|
+
describe 'comparison' do
|
225
227
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
228
|
+
it 'is equal to a background with the same steps' do
|
229
|
+
source = "#{@scenario_keyword}:
|
230
|
+
#{@step_keyword} step 1
|
231
|
+
#{@step_keyword} step 2"
|
232
|
+
scenario = clazz.new(source)
|
230
233
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
234
|
+
source = "#{@background_keyword}:
|
235
|
+
#{@step_keyword} step 1
|
236
|
+
#{@step_keyword} step 2"
|
237
|
+
background_1 = CukeModeler::Background.new(source)
|
235
238
|
|
239
|
+
source = "#{@background_keyword}:
|
240
|
+
#{@step_keyword} step 2
|
241
|
+
#{@step_keyword} step 1"
|
242
|
+
background_2 = CukeModeler::Background.new(source)
|
236
243
|
|
237
|
-
expect(scenario).to eq(background_1)
|
238
|
-
expect(scenario).to_not eq(background_2)
|
239
|
-
end
|
240
244
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
* step 2"
|
245
|
-
scenario_1 = clazz.new(source)
|
245
|
+
expect(scenario).to eq(background_1)
|
246
|
+
expect(scenario).to_not eq(background_2)
|
247
|
+
end
|
246
248
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
249
|
+
it 'is equal to a scenario with the same steps' do
|
250
|
+
source = "#{@scenario_keyword}:
|
251
|
+
#{@step_keyword} step 1
|
252
|
+
#{@step_keyword} step 2"
|
253
|
+
scenario_1 = clazz.new(source)
|
251
254
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
255
|
+
source = "#{@scenario_keyword}:
|
256
|
+
#{@step_keyword} step 1
|
257
|
+
#{@step_keyword} step 2"
|
258
|
+
scenario_2 = clazz.new(source)
|
256
259
|
|
260
|
+
source = "#{@scenario_keyword}:
|
261
|
+
#{@step_keyword} step 2
|
262
|
+
#{@step_keyword} step 1"
|
263
|
+
scenario_3 = clazz.new(source)
|
257
264
|
|
258
|
-
expect(scenario_1).to eq(scenario_2)
|
259
|
-
expect(scenario_1).to_not eq(scenario_3)
|
260
|
-
end
|
261
265
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
* step 2"
|
266
|
-
scenario = clazz.new(source)
|
266
|
+
expect(scenario_1).to eq(scenario_2)
|
267
|
+
expect(scenario_1).to_not eq(scenario_3)
|
268
|
+
end
|
267
269
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
270
|
+
it 'is equal to an outline with the same steps' do
|
271
|
+
source = "#{@scenario_keyword}:
|
272
|
+
#{@step_keyword} step 1
|
273
|
+
#{@step_keyword} step 2"
|
274
|
+
scenario = clazz.new(source)
|
275
|
+
|
276
|
+
source = "#{@outline_keyword}:
|
277
|
+
#{@step_keyword} step 1
|
278
|
+
#{@step_keyword} step 2
|
279
|
+
#{@example_keyword}:
|
272
280
|
| param |
|
273
281
|
| value |"
|
274
|
-
|
282
|
+
outline_1 = CukeModeler::Outline.new(source)
|
275
283
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
284
|
+
source = "#{@outline_keyword}:
|
285
|
+
#{@step_keyword} step 2
|
286
|
+
#{@step_keyword} step 1
|
287
|
+
#{@example_keyword}:
|
280
288
|
| param |
|
281
289
|
| value |"
|
282
|
-
|
290
|
+
outline_2 = CukeModeler::Outline.new(source)
|
283
291
|
|
284
292
|
|
285
|
-
|
286
|
-
|
287
|
-
|
293
|
+
expect(scenario).to eq(outline_1)
|
294
|
+
expect(scenario).to_not eq(outline_2)
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
describe 'scenario output' do
|
301
|
+
|
302
|
+
it 'can be remade from its own output' do
|
303
|
+
source = "@tag1 @tag2 @tag3
|
304
|
+
#{@scenario_keyword}: A scenario with everything it could have
|
305
|
+
|
306
|
+
Including a description
|
307
|
+
and then some.
|
308
|
+
|
309
|
+
#{@step_keyword} a step
|
310
|
+
| value |
|
311
|
+
#{@step_keyword} another step
|
312
|
+
\"\"\"
|
313
|
+
some string
|
314
|
+
\"\"\""
|
315
|
+
scenario = clazz.new(source)
|
316
|
+
|
317
|
+
scenario_output = scenario.to_s
|
318
|
+
remade_scenario_output = clazz.new(scenario_output).to_s
|
288
319
|
|
320
|
+
expect(remade_scenario_output).to eq(scenario_output)
|
289
321
|
end
|
290
322
|
|
291
323
|
|
292
|
-
|
324
|
+
context 'from source text' do
|
293
325
|
|
294
|
-
it 'can
|
295
|
-
source = [
|
296
|
-
'Scenario: A scenario with everything it could have',
|
297
|
-
'',
|
298
|
-
'Including a description',
|
299
|
-
'and then some.',
|
300
|
-
'',
|
301
|
-
' * a step',
|
302
|
-
' | value |',
|
303
|
-
' * another step',
|
304
|
-
' """',
|
305
|
-
' some string',
|
306
|
-
' """']
|
326
|
+
it 'can output an empty scenario' do
|
327
|
+
source = ["#{@scenario_keyword}:"]
|
307
328
|
source = source.join("\n")
|
308
329
|
scenario = clazz.new(source)
|
309
330
|
|
310
|
-
scenario_output = scenario.to_s
|
311
|
-
remade_scenario_output = clazz.new(scenario_output).to_s
|
331
|
+
scenario_output = scenario.to_s.split("\n", -1)
|
312
332
|
|
313
|
-
expect(
|
333
|
+
expect(scenario_output).to eq(["#{@scenario_keyword}:"])
|
314
334
|
end
|
315
335
|
|
336
|
+
it 'can output a scenario that has a name' do
|
337
|
+
source = ["#{@scenario_keyword}: test scenario"]
|
338
|
+
source = source.join("\n")
|
339
|
+
scenario = clazz.new(source)
|
316
340
|
|
317
|
-
|
318
|
-
|
319
|
-
it 'can output an empty scenario' do
|
320
|
-
source = ['Scenario:']
|
321
|
-
source = source.join("\n")
|
322
|
-
scenario = clazz.new(source)
|
323
|
-
|
324
|
-
scenario_output = scenario.to_s.split("\n")
|
341
|
+
scenario_output = scenario.to_s.split("\n", -1)
|
325
342
|
|
326
|
-
|
327
|
-
|
343
|
+
expect(scenario_output).to eq(["#{@scenario_keyword}: test scenario"])
|
344
|
+
end
|
328
345
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
346
|
+
it 'can output a scenario that has a description' do
|
347
|
+
source = ["#{@scenario_keyword}:",
|
348
|
+
'Some description.',
|
349
|
+
'Some more description.']
|
350
|
+
source = source.join("\n")
|
351
|
+
scenario = clazz.new(source)
|
333
352
|
|
334
|
-
|
353
|
+
scenario_output = scenario.to_s.split("\n", -1)
|
335
354
|
|
336
|
-
|
337
|
-
|
355
|
+
expect(scenario_output).to eq(["#{@scenario_keyword}:",
|
356
|
+
'',
|
357
|
+
'Some description.',
|
358
|
+
'Some more description.'])
|
359
|
+
end
|
338
360
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
361
|
+
it 'can output a scenario that has steps' do
|
362
|
+
source = ["#{@scenario_keyword}:",
|
363
|
+
"#{@step_keyword} a step",
|
364
|
+
'|value|',
|
365
|
+
"#{@step_keyword} another step",
|
366
|
+
'"""',
|
367
|
+
'some string',
|
368
|
+
'"""']
|
369
|
+
source = source.join("\n")
|
370
|
+
scenario = clazz.new(source)
|
345
371
|
|
346
|
-
|
372
|
+
scenario_output = scenario.to_s.split("\n", -1)
|
347
373
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
374
|
+
expect(scenario_output).to eq(["#{@scenario_keyword}:",
|
375
|
+
" #{@step_keyword} a step",
|
376
|
+
' | value |',
|
377
|
+
" #{@step_keyword} another step",
|
378
|
+
' """',
|
379
|
+
' some string',
|
380
|
+
' """'])
|
381
|
+
end
|
353
382
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
'some string',
|
361
|
-
'"""']
|
362
|
-
source = source.join("\n")
|
363
|
-
scenario = clazz.new(source)
|
364
|
-
|
365
|
-
scenario_output = scenario.to_s.split("\n")
|
366
|
-
|
367
|
-
expect(scenario_output).to eq(['Scenario:',
|
368
|
-
' * a step',
|
369
|
-
' | value |',
|
370
|
-
' * another step',
|
371
|
-
' """',
|
372
|
-
' some string',
|
373
|
-
' """'])
|
374
|
-
end
|
383
|
+
it 'can output a scenario that has tags' do
|
384
|
+
source = ['@tag1 @tag2',
|
385
|
+
'@tag3',
|
386
|
+
"#{@scenario_keyword}:"]
|
387
|
+
source = source.join("\n")
|
388
|
+
scenario = clazz.new(source)
|
375
389
|
|
376
|
-
|
377
|
-
source = ['@tag1 @tag2',
|
378
|
-
'@tag3',
|
379
|
-
'Scenario:']
|
380
|
-
source = source.join("\n")
|
381
|
-
scenario = clazz.new(source)
|
390
|
+
scenario_output = scenario.to_s.split("\n", -1)
|
382
391
|
|
383
|
-
|
392
|
+
expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
|
393
|
+
"#{@scenario_keyword}:"])
|
394
|
+
end
|
384
395
|
|
385
|
-
|
386
|
-
|
387
|
-
|
396
|
+
it 'can output a scenario that has everything' do
|
397
|
+
source = ['@tag1 @tag2 @tag3',
|
398
|
+
"#{@scenario_keyword}: A scenario with everything it could have",
|
399
|
+
'Including a description',
|
400
|
+
'and then some.',
|
401
|
+
"#{@step_keyword} a step",
|
402
|
+
'|value|',
|
403
|
+
"#{@step_keyword} another step",
|
404
|
+
'"""',
|
405
|
+
'some string',
|
406
|
+
'"""']
|
407
|
+
source = source.join("\n")
|
408
|
+
scenario = clazz.new(source)
|
388
409
|
|
389
|
-
|
390
|
-
source = ['@tag1 @tag2 @tag3',
|
391
|
-
'Scenario: A scenario with everything it could have',
|
392
|
-
'Including a description',
|
393
|
-
'and then some.',
|
394
|
-
'* a step',
|
395
|
-
'|value|',
|
396
|
-
'* another step',
|
397
|
-
'"""',
|
398
|
-
'some string',
|
399
|
-
'"""']
|
400
|
-
source = source.join("\n")
|
401
|
-
scenario = clazz.new(source)
|
402
|
-
|
403
|
-
scenario_output = scenario.to_s.split("\n")
|
404
|
-
|
405
|
-
expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
|
406
|
-
'Scenario: A scenario with everything it could have',
|
407
|
-
'',
|
408
|
-
'Including a description',
|
409
|
-
'and then some.',
|
410
|
-
'',
|
411
|
-
' * a step',
|
412
|
-
' | value |',
|
413
|
-
' * another step',
|
414
|
-
' """',
|
415
|
-
' some string',
|
416
|
-
' """'])
|
417
|
-
end
|
410
|
+
scenario_output = scenario.to_s.split("\n", -1)
|
418
411
|
|
412
|
+
expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
|
413
|
+
"#{@scenario_keyword}: A scenario with everything it could have",
|
414
|
+
'',
|
415
|
+
'Including a description',
|
416
|
+
'and then some.',
|
417
|
+
'',
|
418
|
+
" #{@step_keyword} a step",
|
419
|
+
' | value |',
|
420
|
+
" #{@step_keyword} another step",
|
421
|
+
' """',
|
422
|
+
' some string',
|
423
|
+
' """'])
|
419
424
|
end
|
420
425
|
|
426
|
+
end
|
421
427
|
|
422
|
-
context 'from abstract instantiation' do
|
423
428
|
|
424
|
-
|
429
|
+
context 'from abstract instantiation' do
|
425
430
|
|
431
|
+
let(:scenario) { clazz.new }
|
426
432
|
|
427
|
-
it 'can output a scenario that has only tags' do
|
428
|
-
scenario.tags = [CukeModeler::Tag.new]
|
429
433
|
|
430
|
-
|
431
|
-
|
434
|
+
it 'can output a scenario that has only tags' do
|
435
|
+
scenario.tags = [CukeModeler::Tag.new]
|
432
436
|
|
433
|
-
|
434
|
-
|
437
|
+
expect { scenario.to_s }.to_not raise_error
|
438
|
+
end
|
435
439
|
|
436
|
-
|
437
|
-
|
440
|
+
it 'can output a scenario that has only steps' do
|
441
|
+
scenario.steps = [CukeModeler::Step.new]
|
438
442
|
|
443
|
+
expect { scenario.to_s }.to_not raise_error
|
439
444
|
end
|
440
445
|
|
441
446
|
end
|
@@ -445,5 +450,3 @@ describe 'Scenario, Integration' do
|
|
445
450
|
end
|
446
451
|
|
447
452
|
end
|
448
|
-
|
449
|
-
|