cuke_modeler 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +12 -0
  3. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +5 -5
  4. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +8 -5
  5. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +8 -5
  6. data/lib/cuke_modeler/containing.rb +12 -7
  7. data/lib/cuke_modeler/models/background.rb +7 -2
  8. data/lib/cuke_modeler/models/cell.rb +2 -1
  9. data/lib/cuke_modeler/models/doc_string.rb +2 -1
  10. data/lib/cuke_modeler/models/example.rb +8 -4
  11. data/lib/cuke_modeler/models/feature.rb +4 -1
  12. data/lib/cuke_modeler/models/outline.rb +6 -2
  13. data/lib/cuke_modeler/models/row.rb +2 -1
  14. data/lib/cuke_modeler/models/scenario.rb +7 -2
  15. data/lib/cuke_modeler/models/step.rb +2 -1
  16. data/lib/cuke_modeler/models/table.rb +2 -1
  17. data/lib/cuke_modeler/models/tag.rb +2 -1
  18. data/lib/cuke_modeler/parsing.rb +45 -0
  19. data/lib/cuke_modeler/version.rb +1 -1
  20. data/testing/cucumber/features/modeling/background_modeling.feature +7 -0
  21. data/testing/cucumber/features/modeling/background_output.feature +6 -1
  22. data/testing/cucumber/features/modeling/directory_output.feature +6 -1
  23. data/testing/cucumber/features/modeling/doc_string_output.feature +6 -1
  24. data/testing/cucumber/features/modeling/example_modeling.feature +7 -0
  25. data/testing/cucumber/features/modeling/example_output.feature +6 -1
  26. data/testing/cucumber/features/modeling/feature_file_output.feature +6 -1
  27. data/testing/cucumber/features/modeling/feature_modeling.feature +7 -0
  28. data/testing/cucumber/features/modeling/feature_output.feature +6 -1
  29. data/testing/cucumber/features/modeling/model_output.feature +1 -8
  30. data/testing/cucumber/features/modeling/outline_modeling.feature +7 -0
  31. data/testing/cucumber/features/modeling/outline_output.feature +6 -1
  32. data/testing/cucumber/features/modeling/row_output.feature +6 -1
  33. data/testing/cucumber/features/modeling/scenario_modeling.feature +7 -0
  34. data/testing/cucumber/features/modeling/scenario_output.feature +6 -1
  35. data/testing/cucumber/features/modeling/step_output.feature +6 -1
  36. data/testing/cucumber/features/modeling/table_output.feature +6 -1
  37. data/testing/cucumber/features/modeling/tag_output.feature +6 -1
  38. data/testing/cucumber/step_definitions/verification_steps.rb +21 -12
  39. data/testing/dialect_helper.rb +48 -0
  40. data/testing/rspec/spec/integration/background_integration_spec.rb +93 -88
  41. data/testing/rspec/spec/integration/cell_integration_spec.rb +26 -27
  42. data/testing/rspec/spec/integration/directory_integration_spec.rb +4 -4
  43. data/testing/rspec/spec/integration/doc_string_integration_spec.rb +38 -39
  44. data/testing/rspec/spec/integration/example_integration_spec.rb +97 -95
  45. data/testing/rspec/spec/integration/feature_file_integration_spec.rb +5 -5
  46. data/testing/rspec/spec/integration/feature_integration_spec.rb +157 -155
  47. data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +17 -17
  48. data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +17 -17
  49. data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +17 -17
  50. data/testing/rspec/spec/integration/outline_integration_spec.rb +359 -354
  51. data/testing/rspec/spec/integration/parsing_integration_spec.rb +30 -2
  52. data/testing/rspec/spec/integration/row_integration_spec.rb +23 -25
  53. data/testing/rspec/spec/integration/scenario_integration_spec.rb +238 -235
  54. data/testing/rspec/spec/integration/step_integration_spec.rb +69 -64
  55. data/testing/rspec/spec/integration/table_integration_spec.rb +32 -36
  56. data/testing/rspec/spec/integration/tag_integration_spec.rb +26 -27
  57. data/testing/rspec/spec/spec_helper.rb +43 -0
  58. data/testing/rspec/spec/unit/background_unit_spec.rb +7 -0
  59. data/testing/rspec/spec/unit/example_unit_spec.rb +7 -0
  60. data/testing/rspec/spec/unit/feature_unit_spec.rb +7 -0
  61. data/testing/rspec/spec/unit/outline_unit_spec.rb +7 -0
  62. data/testing/rspec/spec/unit/parsing_unit_spec.rb +33 -0
  63. data/testing/rspec/spec/unit/scenario_unit_spec.rb +7 -0
  64. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +58 -0
  65. data/testing/rspec/spec/unit/step_unit_spec.rb +1 -23
  66. data/testing/test_languages.json +45 -0
  67. data/todo.txt +1 -1
  68. 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('Feature:') }.to_not raise_error
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('Feature:')
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 = ['Feature: Test feature',
70
- '',
71
- ' Scenario: Test test',
72
- ' * a step:',
73
- ' | a | table |']
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 = 'Feature: Test feature
116
+ source = "#{@feature_keyword}: Test feature
118
117
 
119
- Scenario: Test test
120
- * a step:
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 = 'Feature: Test feature
142
+ source = "#{@feature_keyword}: Test feature
144
143
 
145
- Background: Test background
146
- * a step:
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 = 'Feature: Test feature
167
+ source = "#{@feature_keyword}: Test feature
169
168
 
170
- Scenario Outline: Test outline
171
- * a step
172
- Examples:
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 = "Feature: Test feature
221
+ source_text = "#{@feature_keyword}: Test feature
223
222
 
224
- Scenario Outline: Test outline
225
- * a step
226
- Examples:
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 = ['| value1 | value2 |']
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 = 'Scenario:'
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 Scenario:\n And a step\n @foo "
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\nScenario: test scenario\ndescription\n* a step")
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\nScenario: test scenario\ndescription\n* a step")
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\nScenario: test scenario\ndescription\n* a step")
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 = ['@a_tag',
55
- 'Scenario: Test scenario',
56
- ' * a step']
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 = ['Scenario:',
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
- ' * a step']
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 = ['Feature: Test feature',
94
- '',
95
- ' Scenario: Test test',
96
- ' * a step']
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
- context 'from source text' do
132
+ describe 'model population' do
135
133
 
136
- it "models the scenario's source line" do
137
- source_text = "Feature:
134
+ context 'from source text' do
138
135
 
139
- Scenario: foo
140
- * step"
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
- expect(scenario.source_line).to eq(3)
144
- end
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
- context 'a filled scenario' do
155
+ context 'a filled scenario' do
148
156
 
149
- let(:source_text) { '@tag1 @tag2 @tag3
150
- Scenario: Scenario name
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
- * a step
158
- * another step' }
159
- let(:scenario) { clazz.new(source_text) }
165
+ #{@step_keyword} a step
166
+ #{@step_keyword} another step" }
167
+ let(:scenario) { clazz.new(source_text) }
160
168
 
161
169
 
162
- it "models the scenario's name" do
163
- expect(scenario.name).to eq('Scenario name')
164
- end
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
- expect(description).to eq([' Scenario description.',
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
- it "models the scenario's steps" do
176
- step_names = scenario.steps.collect { |step| step.text }
177
+ expect(description).to eq([' Scenario description.',
178
+ '',
179
+ 'Some more.',
180
+ ' Even more.'])
181
+ end
177
182
 
178
- expect(step_names).to eq(['a step', 'another step'])
179
- end
183
+ it "models the scenario's steps" do
184
+ step_names = scenario.steps.collect { |step| step.text }
180
185
 
181
- it "models the scenario's tags" do
182
- tag_names = scenario.tags.collect { |tag| tag.name }
186
+ expect(step_names).to eq(['a step', 'another step'])
187
+ end
183
188
 
184
- expect(tag_names).to eq(['@tag1', '@tag2', '@tag3'])
185
- end
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
- context 'an empty scenario' do
195
+ end
190
196
 
191
- let(:source_text) { 'Scenario:' }
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
- it "models the scenario's description" do
200
- expect(scenario.description).to eq('')
201
- end
203
+ it "models the scenario's name" do
204
+ expect(scenario.name).to eq('')
205
+ end
202
206
 
203
- it "models the scenario's steps" do
204
- expect(scenario.steps).to eq([])
205
- end
207
+ it "models the scenario's description" do
208
+ expect(scenario.description).to eq('')
209
+ end
206
210
 
207
- it "models the scenario's tags" do
208
- expect(scenario.tags).to eq([])
209
- end
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
- it 'is equal to a background with the same steps' do
221
- source = "Scenario:
222
- * step 1
223
- * step 2"
224
- scenario = clazz.new(source)
226
+ describe 'comparison' do
225
227
 
226
- source = "Background:
227
- * step 1
228
- * step 2"
229
- background_1 = CukeModeler::Background.new(source)
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
- source = "Background:
232
- * step 2
233
- * step 1"
234
- background_2 = CukeModeler::Background.new(source)
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
- it 'is equal to a scenario with the same steps' do
242
- source = "Scenario:
243
- * step 1
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
- source = "Scenario:
248
- * step 1
249
- * step 2"
250
- scenario_2 = clazz.new(source)
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
- source = "Scenario:
253
- * step 2
254
- * step 1"
255
- scenario_3 = clazz.new(source)
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
- it 'is equal to an outline with the same steps' do
263
- source = "Scenario:
264
- * step 1
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
- source = "Scenario Outline:
269
- * step 1
270
- * step 2
271
- Examples:
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
- outline_1 = CukeModeler::Outline.new(source)
282
+ outline_1 = CukeModeler::Outline.new(source)
275
283
 
276
- source = "Scenario Outline:
277
- * step 2
278
- * step 1
279
- Examples:
284
+ source = "#{@outline_keyword}:
285
+ #{@step_keyword} step 2
286
+ #{@step_keyword} step 1
287
+ #{@example_keyword}:
280
288
  | param |
281
289
  | value |"
282
- outline_2 = CukeModeler::Outline.new(source)
290
+ outline_2 = CukeModeler::Outline.new(source)
283
291
 
284
292
 
285
- expect(scenario).to eq(outline_1)
286
- expect(scenario).to_not eq(outline_2)
287
- end
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
- describe 'scenario output' do
324
+ context 'from source text' do
293
325
 
294
- it 'can be remade from its own output' do
295
- source = ['@tag1 @tag2 @tag3',
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(remade_scenario_output).to eq(scenario_output)
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
- context 'from source text' do
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
- expect(scenario_output).to eq(['Scenario:'])
327
- end
343
+ expect(scenario_output).to eq(["#{@scenario_keyword}: test scenario"])
344
+ end
328
345
 
329
- it 'can output a scenario that has a name' do
330
- source = ['Scenario: test scenario']
331
- source = source.join("\n")
332
- scenario = clazz.new(source)
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
- scenario_output = scenario.to_s.split("\n")
353
+ scenario_output = scenario.to_s.split("\n", -1)
335
354
 
336
- expect(scenario_output).to eq(['Scenario: test scenario'])
337
- end
355
+ expect(scenario_output).to eq(["#{@scenario_keyword}:",
356
+ '',
357
+ 'Some description.',
358
+ 'Some more description.'])
359
+ end
338
360
 
339
- it 'can output a scenario that has a description' do
340
- source = ['Scenario:',
341
- 'Some description.',
342
- 'Some more description.']
343
- source = source.join("\n")
344
- scenario = clazz.new(source)
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
- scenario_output = scenario.to_s.split("\n")
372
+ scenario_output = scenario.to_s.split("\n", -1)
347
373
 
348
- expect(scenario_output).to eq(['Scenario:',
349
- '',
350
- 'Some description.',
351
- 'Some more description.'])
352
- end
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
- it 'can output a scenario that has steps' do
355
- source = ['Scenario:',
356
- '* a step',
357
- '|value|',
358
- '* another step',
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
- it 'can output a scenario that has tags' do
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
- scenario_output = scenario.to_s.split("\n")
392
+ expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
393
+ "#{@scenario_keyword}:"])
394
+ end
384
395
 
385
- expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
386
- 'Scenario:'])
387
- end
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
- it 'can output a scenario that has everything' do
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
- let(:scenario) { clazz.new }
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
- expect { scenario.to_s }.to_not raise_error
431
- end
434
+ it 'can output a scenario that has only tags' do
435
+ scenario.tags = [CukeModeler::Tag.new]
432
436
 
433
- it 'can output a scenario that has only steps' do
434
- scenario.steps = [CukeModeler::Step.new]
437
+ expect { scenario.to_s }.to_not raise_error
438
+ end
435
439
 
436
- expect { scenario.to_s }.to_not raise_error
437
- end
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
-