cuke_modeler 1.3.0 → 2.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.
- checksums.yaml +5 -5
- data/.travis.yml +60 -17
- data/CHANGELOG.md +312 -0
- data/Gemfile +19 -3
- data/LICENSE.txt +1 -1
- data/README.md +17 -7
- data/Rakefile +45 -28
- data/appveyor.yml +57 -17
- data/cuke_modeler.gemspec +6 -3
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +1 -0
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +1 -0
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +2 -1
- data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +310 -0
- data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +307 -0
- data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +12 -0
- data/lib/cuke_modeler/containing.rb +16 -0
- data/lib/cuke_modeler/described.rb +1 -0
- data/lib/cuke_modeler/models/step.rb +31 -2
- 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 +116 -68
- 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
- data/testing/cucumber/step_definitions/feature_file_steps.rb +1 -1
- data/testing/cucumber/step_definitions/modeling_steps.rb +7 -2
- data/testing/cucumber/step_definitions/verification_steps.rb +11 -2
- data/testing/file_helper.rb +3 -0
- data/testing/gemfiles/gherkin2.gemfile +8 -0
- data/testing/gemfiles/gherkin3.gemfile +6 -0
- data/testing/gemfiles/gherkin4.gemfile +7 -0
- data/testing/gemfiles/gherkin5.gemfile +7 -0
- data/testing/gemfiles/gherkin6.gemfile +10 -0
- data/testing/gemfiles/gherkin7.gemfile +9 -0
- data/testing/gemfiles/gherkin8.gemfile +9 -0
- data/testing/gemfiles/gherkin9.gemfile +9 -0
- data/testing/helper_methods.rb +23 -0
- data/testing/rspec/spec/integration/{gherkin_2_adapter_spec.rb → adapters/gherkin_2_adapter_spec.rb} +13 -13
- data/testing/rspec/spec/integration/{gherkin_3_adapter_spec.rb → adapters/gherkin_3_adapter_spec.rb} +13 -13
- data/testing/rspec/spec/integration/{gherkin_4_adapter_spec.rb → adapters/gherkin_4_adapter_spec.rb} +13 -13
- data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +165 -0
- data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +159 -0
- data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +162 -0
- data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +162 -0
- data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +162 -0
- data/testing/rspec/spec/integration/{background_integration_spec.rb → models/background_integration_spec.rb} +90 -86
- data/testing/rspec/spec/integration/{cell_integration_spec.rb → models/cell_integration_spec.rb} +49 -38
- data/testing/rspec/spec/integration/{comment_integration_spec.rb → models/comment_integration_spec.rb} +31 -20
- data/testing/rspec/spec/integration/{directory_integration_spec.rb → models/directory_integration_spec.rb} +3 -3
- data/testing/rspec/spec/integration/{doc_string_integration_spec.rb → models/doc_string_integration_spec.rb} +39 -35
- data/testing/rspec/spec/integration/{example_integration_spec.rb → models/example_integration_spec.rb} +109 -83
- data/testing/rspec/spec/integration/{feature_file_integration_spec.rb → models/feature_file_integration_spec.rb} +52 -38
- data/testing/rspec/spec/integration/{feature_integration_spec.rb → models/feature_integration_spec.rb} +125 -112
- data/testing/rspec/spec/integration/{model_integration_spec.rb → models/model_integration_spec.rb} +1 -1
- data/testing/rspec/spec/integration/{outline_integration_spec.rb → models/outline_integration_spec.rb} +138 -129
- data/testing/rspec/spec/integration/{row_integration_spec.rb → models/row_integration_spec.rb} +55 -35
- data/testing/rspec/spec/integration/{scenario_integration_spec.rb → models/scenario_integration_spec.rb} +92 -88
- data/testing/rspec/spec/integration/models/step_integration_spec.rb +573 -0
- data/testing/rspec/spec/integration/{table_integration_spec.rb → models/table_integration_spec.rb} +38 -34
- data/testing/rspec/spec/integration/{tag_integration_spec.rb → models/tag_integration_spec.rb} +56 -36
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +45 -7
- data/testing/rspec/spec/spec_helper.rb +79 -43
- data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +25 -0
- data/testing/rspec/spec/unit/{background_unit_spec.rb → models/background_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{cell_unit_spec.rb → models/cell_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{comment_unit_spec.rb → models/comment_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{directory_unit_spec.rb → models/directory_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{doc_string_unit_spec.rb → models/doc_string_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{example_unit_spec.rb → models/example_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{feature_file_unit_spec.rb → models/feature_file_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{feature_unit_spec.rb → models/feature_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{model_unit_spec.rb → models/model_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{outline_unit_spec.rb → models/outline_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{row_unit_spec.rb → models/row_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{scenario_unit_spec.rb → models/scenario_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{step_unit_spec.rb → models/step_unit_spec.rb} +2 -2
- data/testing/rspec/spec/unit/{table_unit_spec.rb → models/table_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/{tag_unit_spec.rb → models/tag_unit_spec.rb} +1 -1
- data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +102 -0
- data/todo.txt +5 -2
- metadata +80 -47
- data/History.md +0 -186
- data/testing/cucumber/support/transforms.rb +0 -3
- data/testing/rspec/spec/integration/step_integration_spec.rb +0 -459
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
describe 'FeatureFile, Integration' do
|
|
@@ -14,34 +14,48 @@ describe 'FeatureFile, Integration' do
|
|
|
14
14
|
|
|
15
15
|
describe 'unique behavior' do
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
test_file_path = CukeModeler::FileHelper.create_feature_file(:text => "#{@feature_keyword}: test feature", :name => 'test_file')
|
|
17
|
+
describe 'parsing data' do
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
|
|
20
|
+
test_file_path = CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}: test feature", :name => 'test_file')
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
22
|
+
feature_file = clazz.new(test_file_path)
|
|
23
|
+
data = feature_file.parsing_data
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
expect(data.keys).to match_array([:uri, :feature, :comments])
|
|
26
|
+
expect(File.basename(data[:uri])).to eq('test_file.feature')
|
|
27
|
+
end
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(4, 5) do
|
|
30
|
+
test_file_path = CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}: test feature", :name => 'test_file')
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
feature_file = clazz.new(test_file_path)
|
|
33
|
+
data = feature_file.parsing_data
|
|
34
|
+
|
|
35
|
+
expect(data.keys).to match_array([:type, :feature, :comments])
|
|
36
|
+
expect(data[:type]).to eq(:GherkinDocument)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(3) do
|
|
40
|
+
test_file_path = CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}: test feature", :name => 'test_file')
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
feature_file = clazz.new(test_file_path)
|
|
43
|
+
data = feature_file.parsing_data
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
# There is no parsing data stored above the feature level for gherkin 3.x
|
|
46
|
+
expect(data).to be_nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
|
|
50
|
+
test_file_path = CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}: test feature", :name => 'test_file')
|
|
51
|
+
|
|
52
|
+
feature_file = clazz.new(test_file_path)
|
|
53
|
+
data = feature_file.parsing_data
|
|
54
|
+
|
|
55
|
+
# There is no parsing data stored above the feature level for gherkin 2.x
|
|
56
|
+
expect(data).to eq([])
|
|
57
|
+
end
|
|
42
58
|
|
|
43
|
-
# There is no parsing data stored above the feature level for gherkin 2.x
|
|
44
|
-
expect(data).to eq([])
|
|
45
59
|
end
|
|
46
60
|
|
|
47
61
|
it 'provides its own filename when being parsed' do
|
|
@@ -59,7 +73,7 @@ describe 'FeatureFile, Integration' do
|
|
|
59
73
|
|
|
60
74
|
describe 'model population' do
|
|
61
75
|
|
|
62
|
-
let(:source_text) { "#{
|
|
76
|
+
let(:source_text) { "#{FEATURE_KEYWORD}: Test feature" }
|
|
63
77
|
let(:feature_file_path) { CukeModeler::FileHelper.create_feature_file }
|
|
64
78
|
let(:feature_file) { clazz.new(feature_file_path) }
|
|
65
79
|
|
|
@@ -84,50 +98,50 @@ describe 'FeatureFile, Integration' do
|
|
|
84
98
|
it "models the feature file's comments" do
|
|
85
99
|
source_text = "# feature comment
|
|
86
100
|
@tag1 @tag2 @tag3
|
|
87
|
-
#{
|
|
101
|
+
#{FEATURE_KEYWORD}: A feature with everything it could have
|
|
88
102
|
|
|
89
103
|
Including a description
|
|
90
104
|
and then some.
|
|
91
105
|
|
|
92
106
|
# background comment
|
|
93
|
-
#{
|
|
107
|
+
#{BACKGROUND_KEYWORD}:
|
|
94
108
|
|
|
95
109
|
Background
|
|
96
110
|
description
|
|
97
111
|
|
|
98
|
-
#{
|
|
112
|
+
#{STEP_KEYWORD} a step
|
|
99
113
|
# table comment
|
|
100
114
|
| value1 |
|
|
101
115
|
# table row comment
|
|
102
116
|
| value2 |
|
|
103
|
-
#{
|
|
117
|
+
#{STEP_KEYWORD} another step
|
|
104
118
|
|
|
105
119
|
# scenario comment
|
|
106
120
|
@scenario_tag
|
|
107
|
-
#{
|
|
121
|
+
#{SCENARIO_KEYWORD}:
|
|
108
122
|
|
|
109
123
|
Scenario
|
|
110
124
|
description
|
|
111
125
|
|
|
112
|
-
#{
|
|
113
|
-
#{
|
|
126
|
+
#{STEP_KEYWORD} a step
|
|
127
|
+
#{STEP_KEYWORD} another step
|
|
114
128
|
\"\"\"
|
|
115
129
|
some text
|
|
116
130
|
\"\"\"
|
|
117
131
|
|
|
118
132
|
# outline comment
|
|
119
133
|
@outline_tag
|
|
120
|
-
#{
|
|
134
|
+
#{OUTLINE_KEYWORD}:
|
|
121
135
|
|
|
122
136
|
Outline
|
|
123
137
|
description
|
|
124
138
|
|
|
125
139
|
# step comment
|
|
126
|
-
#{
|
|
140
|
+
#{STEP_KEYWORD} a step
|
|
127
141
|
# table comment
|
|
128
142
|
| value2 |
|
|
129
143
|
# step comment
|
|
130
|
-
#{
|
|
144
|
+
#{STEP_KEYWORD} another step
|
|
131
145
|
# doc string comment
|
|
132
146
|
\"\"\"
|
|
133
147
|
some text
|
|
@@ -135,7 +149,7 @@ describe 'FeatureFile, Integration' do
|
|
|
135
149
|
|
|
136
150
|
# example comment
|
|
137
151
|
@example_tag
|
|
138
|
-
#{
|
|
152
|
+
#{EXAMPLE_KEYWORD}:
|
|
139
153
|
|
|
140
154
|
Example
|
|
141
155
|
description
|
|
@@ -173,7 +187,7 @@ describe 'FeatureFile, Integration' do
|
|
|
173
187
|
|
|
174
188
|
|
|
175
189
|
# gherkin 3.x does not accept empty feature files
|
|
176
|
-
context 'an empty feature file', :
|
|
190
|
+
context 'an empty feature file', :unless => gherkin?(3) do
|
|
177
191
|
|
|
178
192
|
let(:source_text) { '' }
|
|
179
193
|
|
|
@@ -187,7 +201,7 @@ describe 'FeatureFile, Integration' do
|
|
|
187
201
|
end
|
|
188
202
|
|
|
189
203
|
it 'properly sets its child models' do
|
|
190
|
-
file_path = CukeModeler::FileHelper.create_feature_file(:text => "#{
|
|
204
|
+
file_path = CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}: Test feature", :name => 'test_file')
|
|
191
205
|
|
|
192
206
|
file = clazz.new(file_path)
|
|
193
207
|
feature = file.feature
|
|
@@ -202,7 +216,7 @@ describe 'FeatureFile, Integration' do
|
|
|
202
216
|
let(:feature_file_path) { CukeModeler::FileHelper.create_feature_file(:text => '', :name => 'feature_file_test_file', :directory => directory_path) }
|
|
203
217
|
|
|
204
218
|
before(:each) do
|
|
205
|
-
File.open(feature_file_path, 'w') { |file| file.write("#{
|
|
219
|
+
File.open(feature_file_path, 'w') { |file| file.write("#{FEATURE_KEYWORD}: Test feature") }
|
|
206
220
|
end
|
|
207
221
|
|
|
208
222
|
let(:directory_model) { CukeModeler::Directory.new(directory_path) }
|
|
@@ -228,7 +242,7 @@ describe 'FeatureFile, Integration' do
|
|
|
228
242
|
|
|
229
243
|
context 'from source text' do
|
|
230
244
|
|
|
231
|
-
let(:source_text) { "#{
|
|
245
|
+
let(:source_text) { "#{FEATURE_KEYWORD}: Test feature" }
|
|
232
246
|
let(:feature_file_path) { CukeModeler::FileHelper.create_feature_file(:text => '', :name => 'feature_file_test_file') }
|
|
233
247
|
let(:feature_file) { clazz.new(feature_file_path) }
|
|
234
248
|
|
|
@@ -246,7 +260,7 @@ describe 'FeatureFile, Integration' do
|
|
|
246
260
|
end
|
|
247
261
|
|
|
248
262
|
it 'can be remade from its own output' do
|
|
249
|
-
path = CukeModeler::FileHelper.create_feature_file(:text => "#{
|
|
263
|
+
path = CukeModeler::FileHelper.create_feature_file(:text => "#{FEATURE_KEYWORD}:", :name => 'feature_file_test_file')
|
|
250
264
|
feature_file = clazz.new(path)
|
|
251
265
|
|
|
252
266
|
feature_file_output = feature_file.to_s
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
describe 'Feature, Integration' do
|
|
@@ -16,7 +16,7 @@ describe 'Feature, Integration' do
|
|
|
16
16
|
describe 'unique behavior' do
|
|
17
17
|
|
|
18
18
|
it 'can be instantiated with the minimum viable Gherkin' do
|
|
19
|
-
source = "#{
|
|
19
|
+
source = "#{FEATURE_KEYWORD}:"
|
|
20
20
|
|
|
21
21
|
expect { clazz.new(source) }.to_not raise_error
|
|
22
22
|
end
|
|
@@ -47,11 +47,11 @@ describe 'Feature, Integration' do
|
|
|
47
47
|
|
|
48
48
|
it 'properly sets its child models' do
|
|
49
49
|
source = "@a_tag
|
|
50
|
-
#{
|
|
51
|
-
#{
|
|
52
|
-
#{
|
|
53
|
-
#{
|
|
54
|
-
#{
|
|
50
|
+
#{FEATURE_KEYWORD}: Test feature
|
|
51
|
+
#{BACKGROUND_KEYWORD}: Test background
|
|
52
|
+
#{SCENARIO_KEYWORD}: Test scenario
|
|
53
|
+
#{OUTLINE_KEYWORD}: Test outline
|
|
54
|
+
#{EXAMPLE_KEYWORD}: Test Examples
|
|
55
55
|
| param |
|
|
56
56
|
| value |"
|
|
57
57
|
|
|
@@ -69,32 +69,45 @@ describe 'Feature, Integration' do
|
|
|
69
69
|
expect(tag.parent_model).to equal(feature)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
feature = clazz.new("@tag\n#{@feature_keyword}: test feature\ndescription\n#{@background_keyword}:\n#{@scenario_keyword}:")
|
|
74
|
-
data = feature.parsing_data
|
|
72
|
+
describe 'parsing data' do
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
|
|
75
|
+
feature = clazz.new("@tag\n#{FEATURE_KEYWORD}: test feature\ndescription\n#{BACKGROUND_KEYWORD}:\n#{SCENARIO_KEYWORD}:")
|
|
76
|
+
data = feature.parsing_data
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
expect(data.keys).to match_array([:tags, :location, :language, :keyword, :name, :children, :description])
|
|
79
|
+
expect(data[:name]).to eq('test feature')
|
|
80
|
+
end
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(4, 5) do
|
|
83
|
+
feature = clazz.new("@tag\n#{FEATURE_KEYWORD}: test feature\ndescription\n#{BACKGROUND_KEYWORD}:\n#{SCENARIO_KEYWORD}:")
|
|
84
|
+
data = feature.parsing_data
|
|
87
85
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
expect(data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :children, :description])
|
|
87
|
+
expect(data[:type]).to eq(:Feature)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(3) do
|
|
91
|
+
feature = clazz.new("@tag\n#{FEATURE_KEYWORD}: test feature\ndescription\n#{BACKGROUND_KEYWORD}:\n#{SCENARIO_KEYWORD}:")
|
|
92
|
+
data = feature.parsing_data
|
|
93
|
+
|
|
94
|
+
expect(data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :scenarioDefinitions, :comments, :background, :description])
|
|
95
|
+
expect(data[:type]).to eq(:Feature)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
|
|
99
|
+
feature = clazz.new("@tag\n#{FEATURE_KEYWORD}: test feature\ndescription\n#{BACKGROUND_KEYWORD}:\n#{SCENARIO_KEYWORD}:")
|
|
100
|
+
data = feature.parsing_data
|
|
101
|
+
|
|
102
|
+
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'uri', 'elements', 'tags'])
|
|
103
|
+
expect(data['keyword']).to eq('Feature')
|
|
104
|
+
end
|
|
91
105
|
|
|
92
|
-
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'uri', 'elements', 'tags'])
|
|
93
|
-
expect(data['keyword']).to eq('Feature')
|
|
94
106
|
end
|
|
95
107
|
|
|
108
|
+
|
|
96
109
|
it 'trims whitespace from its source description' do
|
|
97
|
-
source = ["#{
|
|
110
|
+
source = ["#{FEATURE_KEYWORD}:",
|
|
98
111
|
' ',
|
|
99
112
|
' description line 1',
|
|
100
113
|
'',
|
|
@@ -103,7 +116,7 @@ describe 'Feature, Integration' do
|
|
|
103
116
|
'',
|
|
104
117
|
'',
|
|
105
118
|
'',
|
|
106
|
-
" #{
|
|
119
|
+
" #{SCENARIO_KEYWORD}:"]
|
|
107
120
|
source = source.join("\n")
|
|
108
121
|
|
|
109
122
|
feature = clazz.new(source)
|
|
@@ -131,14 +144,14 @@ describe 'Feature, Integration' do
|
|
|
131
144
|
context 'from source text' do
|
|
132
145
|
|
|
133
146
|
it "models the feature's keyword" do
|
|
134
|
-
source_text = "#{
|
|
147
|
+
source_text = "#{FEATURE_KEYWORD}:"
|
|
135
148
|
feature = CukeModeler::Feature.new(source_text)
|
|
136
149
|
|
|
137
|
-
expect(feature.keyword).to eq(
|
|
150
|
+
expect(feature.keyword).to eq(FEATURE_KEYWORD)
|
|
138
151
|
end
|
|
139
152
|
|
|
140
153
|
it "models the feature's source line" do
|
|
141
|
-
source_text = "#{
|
|
154
|
+
source_text = "#{FEATURE_KEYWORD}:"
|
|
142
155
|
feature = CukeModeler::Feature.new(source_text)
|
|
143
156
|
|
|
144
157
|
expect(feature.source_line).to eq(1)
|
|
@@ -148,31 +161,31 @@ describe 'Feature, Integration' do
|
|
|
148
161
|
context 'a filled feature' do
|
|
149
162
|
|
|
150
163
|
let(:source_text) { "@tag_1 @tag_2
|
|
151
|
-
#{
|
|
164
|
+
#{FEATURE_KEYWORD}: Feature Foo
|
|
152
165
|
|
|
153
166
|
Some feature description.
|
|
154
167
|
|
|
155
168
|
Some more.
|
|
156
169
|
And some more.
|
|
157
170
|
|
|
158
|
-
#{
|
|
159
|
-
#{
|
|
171
|
+
#{BACKGROUND_KEYWORD}: The background
|
|
172
|
+
#{STEP_KEYWORD} some setup step
|
|
160
173
|
|
|
161
|
-
#{
|
|
162
|
-
#{
|
|
174
|
+
#{SCENARIO_KEYWORD}: Scenario 1
|
|
175
|
+
#{STEP_KEYWORD} a step
|
|
163
176
|
|
|
164
|
-
#{
|
|
165
|
-
#{
|
|
166
|
-
#{
|
|
177
|
+
#{OUTLINE_KEYWORD}: Outline 1
|
|
178
|
+
#{STEP_KEYWORD} a step
|
|
179
|
+
#{EXAMPLE_KEYWORD}:
|
|
167
180
|
| param |
|
|
168
181
|
| value |
|
|
169
182
|
|
|
170
|
-
#{
|
|
171
|
-
#{
|
|
183
|
+
#{SCENARIO_KEYWORD}: Scenario 2
|
|
184
|
+
#{STEP_KEYWORD} a step
|
|
172
185
|
|
|
173
|
-
#{
|
|
174
|
-
#{
|
|
175
|
-
#{
|
|
186
|
+
#{OUTLINE_KEYWORD}: Outline 2
|
|
187
|
+
#{STEP_KEYWORD} a step
|
|
188
|
+
#{EXAMPLE_KEYWORD}:
|
|
176
189
|
| param |
|
|
177
190
|
| value |" }
|
|
178
191
|
let(:feature) { clazz.new(source_text) }
|
|
@@ -218,7 +231,7 @@ describe 'Feature, Integration' do
|
|
|
218
231
|
|
|
219
232
|
context 'an empty feature' do
|
|
220
233
|
|
|
221
|
-
let(:source_text) { "#{
|
|
234
|
+
let(:source_text) { "#{FEATURE_KEYWORD}:" }
|
|
222
235
|
let(:feature) { clazz.new(source_text) }
|
|
223
236
|
|
|
224
237
|
|
|
@@ -254,13 +267,13 @@ describe 'Feature, Integration' do
|
|
|
254
267
|
|
|
255
268
|
|
|
256
269
|
it 'knows how many test cases it has' do
|
|
257
|
-
source_1 = "#{
|
|
270
|
+
source_1 = "#{FEATURE_KEYWORD}: Test feature"
|
|
258
271
|
|
|
259
|
-
source_2 = "#{
|
|
260
|
-
#{
|
|
261
|
-
#{
|
|
262
|
-
#{
|
|
263
|
-
#{
|
|
272
|
+
source_2 = "#{FEATURE_KEYWORD}: Test feature
|
|
273
|
+
#{SCENARIO_KEYWORD}: Test scenario
|
|
274
|
+
#{OUTLINE_KEYWORD}: Test outline
|
|
275
|
+
#{STEP_KEYWORD} a step
|
|
276
|
+
#{EXAMPLE_KEYWORD}: Test examples
|
|
264
277
|
|param|
|
|
265
278
|
|value_1|
|
|
266
279
|
|value_2|"
|
|
@@ -282,7 +295,7 @@ describe 'Feature, Integration' do
|
|
|
282
295
|
|
|
283
296
|
|
|
284
297
|
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
|
285
|
-
let(:source_gherkin) { "#{
|
|
298
|
+
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature" }
|
|
286
299
|
|
|
287
300
|
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
|
288
301
|
let(:feature_model) { directory_model.feature_files.first.feature }
|
|
@@ -313,47 +326,47 @@ describe 'Feature, Integration' do
|
|
|
313
326
|
|
|
314
327
|
it 'can be remade from its own output' do
|
|
315
328
|
source = "@tag1 @tag2 @tag3
|
|
316
|
-
#{
|
|
329
|
+
#{FEATURE_KEYWORD}: A feature with everything it could have
|
|
317
330
|
|
|
318
331
|
Including a description
|
|
319
332
|
and then some.
|
|
320
333
|
|
|
321
|
-
#{
|
|
334
|
+
#{BACKGROUND_KEYWORD}:
|
|
322
335
|
|
|
323
336
|
Background
|
|
324
337
|
description
|
|
325
338
|
|
|
326
|
-
#{
|
|
339
|
+
#{STEP_KEYWORD} a step
|
|
327
340
|
| value1 |
|
|
328
|
-
#{
|
|
341
|
+
#{STEP_KEYWORD} another step
|
|
329
342
|
|
|
330
343
|
@scenario_tag
|
|
331
|
-
#{
|
|
344
|
+
#{SCENARIO_KEYWORD}:
|
|
332
345
|
|
|
333
346
|
Scenario
|
|
334
347
|
description
|
|
335
348
|
|
|
336
|
-
#{
|
|
337
|
-
#{
|
|
349
|
+
#{STEP_KEYWORD} a step
|
|
350
|
+
#{STEP_KEYWORD} another step
|
|
338
351
|
\"\"\"
|
|
339
352
|
some text
|
|
340
353
|
\"\"\"
|
|
341
354
|
|
|
342
355
|
@outline_tag
|
|
343
|
-
#{
|
|
356
|
+
#{OUTLINE_KEYWORD}:
|
|
344
357
|
|
|
345
358
|
Outline
|
|
346
359
|
description
|
|
347
360
|
|
|
348
|
-
#{
|
|
361
|
+
#{STEP_KEYWORD} a step
|
|
349
362
|
| value2 |
|
|
350
|
-
#{
|
|
363
|
+
#{STEP_KEYWORD} another step
|
|
351
364
|
\"\"\"
|
|
352
365
|
some text
|
|
353
366
|
\"\"\"
|
|
354
367
|
|
|
355
368
|
@example_tag
|
|
356
|
-
#{
|
|
369
|
+
#{EXAMPLE_KEYWORD}:
|
|
357
370
|
|
|
358
371
|
Example
|
|
359
372
|
description
|
|
@@ -372,27 +385,27 @@ describe 'Feature, Integration' do
|
|
|
372
385
|
context 'from source text' do
|
|
373
386
|
|
|
374
387
|
it 'can output an empty feature' do
|
|
375
|
-
source = ["#{
|
|
388
|
+
source = ["#{FEATURE_KEYWORD}:"]
|
|
376
389
|
source = source.join("\n")
|
|
377
390
|
feature = clazz.new(source)
|
|
378
391
|
|
|
379
392
|
feature_output = feature.to_s.split("\n", -1)
|
|
380
393
|
|
|
381
|
-
expect(feature_output).to eq(["#{
|
|
394
|
+
expect(feature_output).to eq(["#{FEATURE_KEYWORD}:"])
|
|
382
395
|
end
|
|
383
396
|
|
|
384
397
|
it 'can output a feature that has a name' do
|
|
385
|
-
source = ["#{
|
|
398
|
+
source = ["#{FEATURE_KEYWORD}: test feature"]
|
|
386
399
|
source = source.join("\n")
|
|
387
400
|
feature = clazz.new(source)
|
|
388
401
|
|
|
389
402
|
feature_output = feature.to_s.split("\n", -1)
|
|
390
403
|
|
|
391
|
-
expect(feature_output).to eq(["#{
|
|
404
|
+
expect(feature_output).to eq(["#{FEATURE_KEYWORD}: test feature"])
|
|
392
405
|
end
|
|
393
406
|
|
|
394
407
|
it 'can output a feature that has a description' do
|
|
395
|
-
source = ["#{
|
|
408
|
+
source = ["#{FEATURE_KEYWORD}:",
|
|
396
409
|
'Some description.',
|
|
397
410
|
'Some more description.']
|
|
398
411
|
source = source.join("\n")
|
|
@@ -400,7 +413,7 @@ describe 'Feature, Integration' do
|
|
|
400
413
|
|
|
401
414
|
feature_output = feature.to_s.split("\n", -1)
|
|
402
415
|
|
|
403
|
-
expect(feature_output).to eq(["#{
|
|
416
|
+
expect(feature_output).to eq(["#{FEATURE_KEYWORD}:",
|
|
404
417
|
'',
|
|
405
418
|
'Some description.',
|
|
406
419
|
'Some more description.'])
|
|
@@ -409,51 +422,51 @@ describe 'Feature, Integration' do
|
|
|
409
422
|
it 'can output a feature that has tags' do
|
|
410
423
|
source = ['@tag1 @tag2',
|
|
411
424
|
'@tag3',
|
|
412
|
-
"#{
|
|
425
|
+
"#{FEATURE_KEYWORD}:"]
|
|
413
426
|
source = source.join("\n")
|
|
414
427
|
feature = clazz.new(source)
|
|
415
428
|
|
|
416
429
|
feature_output = feature.to_s.split("\n", -1)
|
|
417
430
|
|
|
418
431
|
expect(feature_output).to eq(['@tag1 @tag2 @tag3',
|
|
419
|
-
"#{
|
|
432
|
+
"#{FEATURE_KEYWORD}:"])
|
|
420
433
|
end
|
|
421
434
|
|
|
422
435
|
it 'can output a feature that has a background' do
|
|
423
|
-
source = ["#{
|
|
424
|
-
"#{
|
|
425
|
-
"#{
|
|
436
|
+
source = ["#{FEATURE_KEYWORD}:",
|
|
437
|
+
"#{BACKGROUND_KEYWORD}:",
|
|
438
|
+
"#{STEP_KEYWORD} a step"]
|
|
426
439
|
source = source.join("\n")
|
|
427
440
|
feature = clazz.new(source)
|
|
428
441
|
|
|
429
442
|
feature_output = feature.to_s.split("\n", -1)
|
|
430
443
|
|
|
431
|
-
expect(feature_output).to eq(["#{
|
|
444
|
+
expect(feature_output).to eq(["#{FEATURE_KEYWORD}:",
|
|
432
445
|
'',
|
|
433
|
-
" #{
|
|
434
|
-
" #{
|
|
446
|
+
" #{BACKGROUND_KEYWORD}:",
|
|
447
|
+
" #{STEP_KEYWORD} a step"])
|
|
435
448
|
end
|
|
436
449
|
|
|
437
450
|
it 'can output a feature that has a scenario' do
|
|
438
|
-
source = ["#{
|
|
439
|
-
"#{
|
|
440
|
-
"#{
|
|
451
|
+
source = ["#{FEATURE_KEYWORD}:",
|
|
452
|
+
"#{SCENARIO_KEYWORD}:",
|
|
453
|
+
"#{STEP_KEYWORD} a step"]
|
|
441
454
|
source = source.join("\n")
|
|
442
455
|
feature = clazz.new(source)
|
|
443
456
|
|
|
444
457
|
feature_output = feature.to_s.split("\n", -1)
|
|
445
458
|
|
|
446
|
-
expect(feature_output).to eq(["#{
|
|
459
|
+
expect(feature_output).to eq(["#{FEATURE_KEYWORD}:",
|
|
447
460
|
'',
|
|
448
|
-
" #{
|
|
449
|
-
" #{
|
|
461
|
+
" #{SCENARIO_KEYWORD}:",
|
|
462
|
+
" #{STEP_KEYWORD} a step"])
|
|
450
463
|
end
|
|
451
464
|
|
|
452
465
|
it 'can output a feature that has an outline' do
|
|
453
|
-
source = ["#{
|
|
454
|
-
"#{
|
|
455
|
-
"#{
|
|
456
|
-
"#{
|
|
466
|
+
source = ["#{FEATURE_KEYWORD}:",
|
|
467
|
+
"#{OUTLINE_KEYWORD}:",
|
|
468
|
+
"#{STEP_KEYWORD} a step",
|
|
469
|
+
"#{EXAMPLE_KEYWORD}:",
|
|
457
470
|
'|param|',
|
|
458
471
|
'|value|']
|
|
459
472
|
source = source.join("\n")
|
|
@@ -461,48 +474,48 @@ describe 'Feature, Integration' do
|
|
|
461
474
|
|
|
462
475
|
feature_output = feature.to_s.split("\n", -1)
|
|
463
476
|
|
|
464
|
-
expect(feature_output).to eq(["#{
|
|
477
|
+
expect(feature_output).to eq(["#{FEATURE_KEYWORD}:",
|
|
465
478
|
'',
|
|
466
|
-
" #{
|
|
467
|
-
" #{
|
|
479
|
+
" #{OUTLINE_KEYWORD}:",
|
|
480
|
+
" #{STEP_KEYWORD} a step",
|
|
468
481
|
'',
|
|
469
|
-
" #{
|
|
482
|
+
" #{EXAMPLE_KEYWORD}:",
|
|
470
483
|
' | param |',
|
|
471
484
|
' | value |'])
|
|
472
485
|
end
|
|
473
486
|
|
|
474
487
|
it 'can output a feature that has everything' do
|
|
475
488
|
source = ['@tag1 @tag2 @tag3',
|
|
476
|
-
"#{
|
|
489
|
+
"#{FEATURE_KEYWORD}: A feature with everything it could have",
|
|
477
490
|
'Including a description',
|
|
478
491
|
'and then some.',
|
|
479
|
-
"#{
|
|
492
|
+
"#{BACKGROUND_KEYWORD}:",
|
|
480
493
|
'Background',
|
|
481
494
|
'description',
|
|
482
|
-
"#{
|
|
495
|
+
"#{STEP_KEYWORD} a step",
|
|
483
496
|
'|value1|',
|
|
484
|
-
"#{
|
|
497
|
+
"#{STEP_KEYWORD} another step",
|
|
485
498
|
'@scenario_tag',
|
|
486
|
-
"#{
|
|
499
|
+
"#{SCENARIO_KEYWORD}:",
|
|
487
500
|
'Scenario',
|
|
488
501
|
'description',
|
|
489
|
-
"#{
|
|
490
|
-
"#{
|
|
502
|
+
"#{STEP_KEYWORD} a step",
|
|
503
|
+
"#{STEP_KEYWORD} another step",
|
|
491
504
|
'"""',
|
|
492
505
|
'some text',
|
|
493
506
|
'"""',
|
|
494
507
|
'@outline_tag',
|
|
495
|
-
"#{
|
|
508
|
+
"#{OUTLINE_KEYWORD}:",
|
|
496
509
|
'Outline ',
|
|
497
510
|
'description',
|
|
498
|
-
"#{
|
|
511
|
+
"#{STEP_KEYWORD} a step ",
|
|
499
512
|
'|value2|',
|
|
500
|
-
"#{
|
|
513
|
+
"#{STEP_KEYWORD} another step",
|
|
501
514
|
'"""',
|
|
502
515
|
'some text',
|
|
503
516
|
'"""',
|
|
504
517
|
'@example_tag',
|
|
505
|
-
"#{
|
|
518
|
+
"#{EXAMPLE_KEYWORD}:",
|
|
506
519
|
'Example',
|
|
507
520
|
'description',
|
|
508
521
|
'|param|',
|
|
@@ -513,47 +526,47 @@ describe 'Feature, Integration' do
|
|
|
513
526
|
feature_output = feature.to_s.split("\n", -1)
|
|
514
527
|
|
|
515
528
|
expect(feature_output).to eq(['@tag1 @tag2 @tag3',
|
|
516
|
-
"#{
|
|
529
|
+
"#{FEATURE_KEYWORD}: A feature with everything it could have",
|
|
517
530
|
'',
|
|
518
531
|
'Including a description',
|
|
519
532
|
'and then some.',
|
|
520
533
|
'',
|
|
521
|
-
" #{
|
|
534
|
+
" #{BACKGROUND_KEYWORD}:",
|
|
522
535
|
'',
|
|
523
536
|
' Background',
|
|
524
537
|
' description',
|
|
525
538
|
'',
|
|
526
|
-
" #{
|
|
539
|
+
" #{STEP_KEYWORD} a step",
|
|
527
540
|
' | value1 |',
|
|
528
|
-
" #{
|
|
541
|
+
" #{STEP_KEYWORD} another step",
|
|
529
542
|
'',
|
|
530
543
|
' @scenario_tag',
|
|
531
|
-
" #{
|
|
544
|
+
" #{SCENARIO_KEYWORD}:",
|
|
532
545
|
'',
|
|
533
546
|
' Scenario',
|
|
534
547
|
' description',
|
|
535
548
|
'',
|
|
536
|
-
" #{
|
|
537
|
-
" #{
|
|
549
|
+
" #{STEP_KEYWORD} a step",
|
|
550
|
+
" #{STEP_KEYWORD} another step",
|
|
538
551
|
' """',
|
|
539
552
|
' some text',
|
|
540
553
|
' """',
|
|
541
554
|
'',
|
|
542
555
|
' @outline_tag',
|
|
543
|
-
" #{
|
|
556
|
+
" #{OUTLINE_KEYWORD}:",
|
|
544
557
|
'',
|
|
545
558
|
' Outline',
|
|
546
559
|
' description',
|
|
547
560
|
'',
|
|
548
|
-
" #{
|
|
561
|
+
" #{STEP_KEYWORD} a step",
|
|
549
562
|
' | value2 |',
|
|
550
|
-
" #{
|
|
563
|
+
" #{STEP_KEYWORD} another step",
|
|
551
564
|
' """',
|
|
552
565
|
' some text',
|
|
553
566
|
' """',
|
|
554
567
|
'',
|
|
555
568
|
' @example_tag',
|
|
556
|
-
" #{
|
|
569
|
+
" #{EXAMPLE_KEYWORD}:",
|
|
557
570
|
'',
|
|
558
571
|
' Example',
|
|
559
572
|
' description',
|
|
@@ -624,7 +637,7 @@ describe 'Feature, Integration' do
|
|
|
624
637
|
end
|
|
625
638
|
|
|
626
639
|
|
|
627
|
-
expect { clazz.new("#{
|
|
640
|
+
expect { clazz.new("#{FEATURE_KEYWORD}:\n#{SCENARIO_KEYWORD}:\n#{STEP_KEYWORD} foo") }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
|
|
628
641
|
ensure
|
|
629
642
|
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
|
630
643
|
module CukeModeler
|