cuke_modeler 1.1.1 → 1.2.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 +5 -0
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +77 -22
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +25 -1
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +25 -1
- data/lib/cuke_modeler/containing.rb +15 -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 +47 -0
- data/lib/cuke_modeler/models/directory.rb +2 -5
- 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 +8 -5
- 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 +1 -1
- data/lib/cuke_modeler/models/table.rb +1 -1
- data/lib/cuke_modeler/models/tag.rb +1 -1
- data/lib/cuke_modeler/version.rb +1 -1
- data/lib/cuke_modeler.rb +1 -0
- data/testing/cucumber/features/modeling/comment_modeling.feature +43 -0
- data/testing/cucumber/features/modeling/comment_output.feature +27 -0
- data/testing/cucumber/features/modeling/feature_file_modeling.feature +11 -0
- data/testing/cucumber/features/modeling/model_structure.feature +2 -2
- data/testing/cucumber/features/modeling/tag_output.feature +1 -1
- data/testing/cucumber/step_definitions/feature_file_steps.rb +10 -0
- data/testing/cucumber/step_definitions/setup_steps.rb +6 -0
- data/testing/cucumber/step_definitions/verification_steps.rb +7 -1
- data/testing/rspec/spec/integration/comment_integration_spec.rb +168 -0
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +124 -0
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +36 -3
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +28 -4
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +28 -3
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +1 -0
- data/testing/rspec/spec/unit/comment_unit_spec.rb +74 -0
- data/testing/rspec/spec/unit/feature_file_unit_spec.rb +18 -0
- data/todo.txt +2 -0
- metadata +7 -2
@@ -14,6 +14,39 @@ describe 'FeatureFile, Integration' do
|
|
14
14
|
|
15
15
|
describe 'unique behavior' do
|
16
16
|
|
17
|
+
it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
|
18
|
+
path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
19
|
+
File.open(path, "w") { |file| file.puts "#{@feature_keyword}: test feature" }
|
20
|
+
|
21
|
+
feature_file = clazz.new(path)
|
22
|
+
data = feature_file.parsing_data
|
23
|
+
|
24
|
+
expect(data.keys).to match_array([:type, :feature, :comments])
|
25
|
+
expect(data[:type]).to eq(:GherkinDocument)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
29
|
+
path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
30
|
+
File.open(path, "w") { |file| file.puts "#{@feature_keyword}: test feature" }
|
31
|
+
|
32
|
+
feature_file = clazz.new(path)
|
33
|
+
data = feature_file.parsing_data
|
34
|
+
|
35
|
+
# There is no parsing data stored above the feature level for gherkin 3.x
|
36
|
+
expect(data).to be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
40
|
+
path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
41
|
+
File.open(path, "w") { |file| file.puts "#{@feature_keyword}: test feature" }
|
42
|
+
|
43
|
+
feature_file = clazz.new(path)
|
44
|
+
data = feature_file.parsing_data
|
45
|
+
|
46
|
+
# There is no parsing data stored above the feature level for gherkin 2.x
|
47
|
+
expect(data).to eq([])
|
48
|
+
end
|
49
|
+
|
17
50
|
it 'provides its own filename when being parsed' do
|
18
51
|
path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
19
52
|
File.open(path, "w") { |file| file.puts 'bad feature text' }
|
@@ -52,6 +85,97 @@ describe 'FeatureFile, Integration' do
|
|
52
85
|
expect(feature_name).to eq('Test feature')
|
53
86
|
end
|
54
87
|
|
88
|
+
it "models the feature file's comments" do
|
89
|
+
source_text = "# feature comment
|
90
|
+
@tag1 @tag2 @tag3
|
91
|
+
#{@feature_keyword}: A feature with everything it could have
|
92
|
+
|
93
|
+
Including a description
|
94
|
+
and then some.
|
95
|
+
|
96
|
+
# background comment
|
97
|
+
#{@background_keyword}:
|
98
|
+
|
99
|
+
Background
|
100
|
+
description
|
101
|
+
|
102
|
+
#{@step_keyword} a step
|
103
|
+
# table comment
|
104
|
+
| value1 |
|
105
|
+
# table row comment
|
106
|
+
| value2 |
|
107
|
+
#{@step_keyword} another step
|
108
|
+
|
109
|
+
# scenario comment
|
110
|
+
@scenario_tag
|
111
|
+
#{@scenario_keyword}:
|
112
|
+
|
113
|
+
Scenario
|
114
|
+
description
|
115
|
+
|
116
|
+
#{@step_keyword} a step
|
117
|
+
#{@step_keyword} another step
|
118
|
+
\"\"\"
|
119
|
+
some text
|
120
|
+
\"\"\"
|
121
|
+
|
122
|
+
# outline comment
|
123
|
+
@outline_tag
|
124
|
+
#{@outline_keyword}:
|
125
|
+
|
126
|
+
Outline
|
127
|
+
description
|
128
|
+
|
129
|
+
# step comment
|
130
|
+
#{@step_keyword} a step
|
131
|
+
# table comment
|
132
|
+
| value2 |
|
133
|
+
# step comment
|
134
|
+
#{@step_keyword} another step
|
135
|
+
# doc string comment
|
136
|
+
\"\"\"
|
137
|
+
some text
|
138
|
+
\"\"\"
|
139
|
+
|
140
|
+
# example comment
|
141
|
+
@example_tag
|
142
|
+
#{@example_keyword}:
|
143
|
+
|
144
|
+
Example
|
145
|
+
description
|
146
|
+
|
147
|
+
# row comment
|
148
|
+
| param |
|
149
|
+
| value |
|
150
|
+
# final comment"
|
151
|
+
|
152
|
+
File.open(feature_file_path, "w") { |file| file.puts source_text }
|
153
|
+
|
154
|
+
feature_file = clazz.new(feature_file_path)
|
155
|
+
comments = feature_file.comments.collect { |comment| comment.text }
|
156
|
+
|
157
|
+
|
158
|
+
expected_comments = ['# feature comment',
|
159
|
+
'# background comment',
|
160
|
+
'# table comment',
|
161
|
+
'# table row comment',
|
162
|
+
'# scenario comment',
|
163
|
+
'# outline comment',
|
164
|
+
'# step comment',
|
165
|
+
'# table comment',
|
166
|
+
'# step comment',
|
167
|
+
'# doc string comment',
|
168
|
+
'# example comment',
|
169
|
+
'# row comment']
|
170
|
+
|
171
|
+
# gherkin 2.x 'loses' comments that are not followed by some element
|
172
|
+
expected_comments << '# final comment' unless Gem.loaded_specs['gherkin'].version.version[/^2/]
|
173
|
+
|
174
|
+
|
175
|
+
expect(comments).to match_array(expected_comments)
|
176
|
+
end
|
177
|
+
|
178
|
+
|
55
179
|
# gherkin 3.x does not accept empty feature files
|
56
180
|
context 'an empty feature file', :gherkin3 => false do
|
57
181
|
|
@@ -3,21 +3,27 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
|
|
3
3
|
|
4
4
|
describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
|
5
5
|
|
6
|
-
let(:source_text) { "
|
6
|
+
let(:source_text) { "# feature comment
|
7
|
+
@tag1 @tag2 @tag3
|
7
8
|
#{@feature_keyword}: A feature with everything it could have
|
8
9
|
|
9
10
|
Including a description
|
10
11
|
and then some.
|
11
12
|
|
13
|
+
# background comment
|
12
14
|
#{@background_keyword}:
|
13
15
|
|
14
16
|
Background
|
15
17
|
description
|
16
18
|
|
17
19
|
#{@step_keyword} a step
|
20
|
+
# table comment
|
18
21
|
| value1 |
|
22
|
+
# table row comment
|
23
|
+
| value2 |
|
19
24
|
#{@step_keyword} another step
|
20
25
|
|
26
|
+
# scenario comment
|
21
27
|
@scenario_tag
|
22
28
|
#{@scenario_keyword}:
|
23
29
|
|
@@ -30,33 +36,52 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
|
|
30
36
|
some text
|
31
37
|
\"\"\"
|
32
38
|
|
39
|
+
# outline comment
|
33
40
|
@outline_tag
|
34
41
|
#{@outline_keyword}:
|
35
42
|
|
36
43
|
Outline
|
37
44
|
description
|
38
45
|
|
46
|
+
# step comment
|
39
47
|
#{@step_keyword} a step
|
48
|
+
# table comment
|
40
49
|
| value2 |
|
50
|
+
# step comment
|
41
51
|
#{@step_keyword} another step
|
52
|
+
# doc string comment
|
42
53
|
\"\"\"
|
43
54
|
some text
|
44
55
|
\"\"\"
|
45
56
|
|
57
|
+
# example comment
|
46
58
|
@example_tag
|
47
59
|
#{@example_keyword}:
|
48
60
|
|
49
61
|
Example
|
50
62
|
description
|
51
63
|
|
64
|
+
# row comment
|
52
65
|
| param |
|
53
|
-
| value |
|
54
|
-
|
66
|
+
| value |
|
67
|
+
# final comment" }
|
68
|
+
let(:feature_file) { path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
69
|
+
File.open(path, "w") { |file| file.puts source_text }
|
70
|
+
|
71
|
+
CukeModeler::FeatureFile.new(path) }
|
72
|
+
let(:feature) { feature_file.feature }
|
73
|
+
|
55
74
|
|
75
|
+
it "does not store parsing data for a feature file's children" do
|
76
|
+
model = feature_file
|
77
|
+
|
78
|
+
expect(model.parsing_data).to eq([])
|
79
|
+
end
|
56
80
|
|
57
81
|
it "does not store parsing data for a feature's children" do
|
58
82
|
model = feature
|
59
83
|
|
84
|
+
expect(model.parsing_data['comments']).to be_nil
|
60
85
|
expect(model.parsing_data['tags']).to be_nil
|
61
86
|
expect(model.parsing_data['elements']).to be_nil
|
62
87
|
end
|
@@ -64,12 +89,14 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
|
|
64
89
|
it "does not store parsing data for a background's children" do
|
65
90
|
model = feature.background
|
66
91
|
|
92
|
+
expect(model.parsing_data['comments']).to be_nil
|
67
93
|
expect(model.parsing_data['steps']).to be_nil
|
68
94
|
end
|
69
95
|
|
70
96
|
it "does not store parsing data for a scenario's children" do
|
71
97
|
model = feature.scenarios.first
|
72
98
|
|
99
|
+
expect(model.parsing_data['comments']).to be_nil
|
73
100
|
expect(model.parsing_data['tags']).to be_nil
|
74
101
|
expect(model.parsing_data['steps']).to be_nil
|
75
102
|
end
|
@@ -77,6 +104,7 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
|
|
77
104
|
it "does not store parsing data for an outline's children" do
|
78
105
|
model = feature.outlines.first
|
79
106
|
|
107
|
+
expect(model.parsing_data['comments']).to be_nil
|
80
108
|
expect(model.parsing_data['tags']).to be_nil
|
81
109
|
expect(model.parsing_data['steps']).to be_nil
|
82
110
|
expect(model.parsing_data['examples']).to be_nil
|
@@ -85,6 +113,7 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
|
|
85
113
|
it "does not store parsing data for an example's children" do
|
86
114
|
model = feature.outlines.first.examples.first
|
87
115
|
|
116
|
+
expect(model.parsing_data['comments']).to be_nil
|
88
117
|
expect(model.parsing_data['tags']).to be_nil
|
89
118
|
expect(model.parsing_data['rows']).to be_nil
|
90
119
|
end
|
@@ -92,18 +121,21 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
|
|
92
121
|
it "does not store parsing data for an example row's children" do
|
93
122
|
model = feature.outlines.first.examples.first.rows.first
|
94
123
|
|
124
|
+
expect(model.parsing_data['comments']).to be_nil
|
95
125
|
expect(model.parsing_data['cells']).to be_nil
|
96
126
|
end
|
97
127
|
|
98
128
|
it "does not store parsing data for a step's children, table" do
|
99
129
|
model = feature.outlines.first.steps.first
|
100
130
|
|
131
|
+
expect(model.parsing_data['comments']).to be_nil
|
101
132
|
expect(model.parsing_data['rows']).to be_nil
|
102
133
|
end
|
103
134
|
|
104
135
|
it "does not store parsing data for a step's children, doc string" do
|
105
136
|
model = feature.outlines.first.steps.last
|
106
137
|
|
138
|
+
expect(model.parsing_data['comments']).to be_nil
|
107
139
|
expect(model.parsing_data['doc_string']).to be_nil
|
108
140
|
end
|
109
141
|
|
@@ -116,6 +148,7 @@ describe 'Gherkin2Adapter, Integration', :gherkin2 => true do
|
|
116
148
|
it "does not store parsing data for a table row's children" do
|
117
149
|
model = feature.outlines.first.steps.first.block.rows.first
|
118
150
|
|
151
|
+
expect(model.parsing_data['comments']).to be_nil
|
119
152
|
expect(model.parsing_data['cells']).to be_nil
|
120
153
|
end
|
121
154
|
|
@@ -3,21 +3,27 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
|
|
3
3
|
|
4
4
|
describe 'Gherkin3Adapter, Integration', :gherkin3 => true do
|
5
5
|
|
6
|
-
let(:source_text) { "
|
6
|
+
let(:source_text) { "# feature comment
|
7
|
+
@tag1 @tag2 @tag3
|
7
8
|
#{@feature_keyword}: A feature with everything it could have
|
8
9
|
|
9
10
|
Including a description
|
10
11
|
and then some.
|
11
12
|
|
13
|
+
# background comment
|
12
14
|
#{@background_keyword}:
|
13
15
|
|
14
16
|
Background
|
15
17
|
description
|
16
18
|
|
17
19
|
#{@step_keyword} a step
|
20
|
+
# table comment
|
18
21
|
| value1 |
|
22
|
+
# table row comment
|
23
|
+
| value2 |
|
19
24
|
#{@step_keyword} another step
|
20
25
|
|
26
|
+
# scenario comment
|
21
27
|
@scenario_tag
|
22
28
|
#{@scenario_keyword}:
|
23
29
|
|
@@ -30,33 +36,52 @@ describe 'Gherkin3Adapter, Integration', :gherkin3 => true do
|
|
30
36
|
some text
|
31
37
|
\"\"\"
|
32
38
|
|
39
|
+
# outline comment
|
33
40
|
@outline_tag
|
34
41
|
#{@outline_keyword}:
|
35
42
|
|
36
43
|
Outline
|
37
44
|
description
|
38
45
|
|
46
|
+
# step comment
|
39
47
|
#{@step_keyword} a step
|
48
|
+
# table comment
|
40
49
|
| value2 |
|
50
|
+
# step comment
|
41
51
|
#{@step_keyword} another step
|
52
|
+
# doc string comment
|
42
53
|
\"\"\"
|
43
54
|
some text
|
44
55
|
\"\"\"
|
45
56
|
|
57
|
+
# example comment
|
46
58
|
@example_tag
|
47
59
|
#{@example_keyword}:
|
48
60
|
|
49
61
|
Example
|
50
62
|
description
|
51
63
|
|
64
|
+
# row comment
|
52
65
|
| param |
|
53
|
-
| value |
|
54
|
-
|
66
|
+
| value |
|
67
|
+
# final comment" }
|
68
|
+
let(:feature_file) { path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
69
|
+
File.open(path, "w") { |file| file.puts source_text }
|
70
|
+
|
71
|
+
CukeModeler::FeatureFile.new(path) }
|
72
|
+
let(:feature) { feature_file.feature }
|
73
|
+
|
55
74
|
|
75
|
+
it "does not store parsing data for a feature file's children" do
|
76
|
+
model = feature_file
|
77
|
+
|
78
|
+
expect(model.parsing_data).to be_nil
|
79
|
+
end
|
56
80
|
|
57
81
|
it "does not store parsing data for a feature's children" do
|
58
82
|
model = feature
|
59
83
|
|
84
|
+
expect(model.parsing_data[:comments]).to be_nil
|
60
85
|
expect(model.parsing_data[:tags]).to be_nil
|
61
86
|
expect(model.parsing_data[:scenarioDefinitions]).to be_nil
|
62
87
|
expect(model.parsing_data[:background]).to be_nil
|
@@ -121,5 +146,4 @@ describe 'Gherkin3Adapter, Integration', :gherkin3 => true do
|
|
121
146
|
expect(model.parsing_data[:cells]).to be_nil
|
122
147
|
end
|
123
148
|
|
124
|
-
|
125
149
|
end
|
@@ -3,21 +3,27 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
|
|
3
3
|
|
4
4
|
describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
|
5
5
|
|
6
|
-
let(:source_text) { "
|
6
|
+
let(:source_text) { "# feature comment
|
7
|
+
@tag1 @tag2 @tag3
|
7
8
|
#{@feature_keyword}: A feature with everything it could have
|
8
9
|
|
9
10
|
Including a description
|
10
11
|
and then some.
|
11
12
|
|
13
|
+
# background comment
|
12
14
|
#{@background_keyword}:
|
13
15
|
|
14
16
|
Background
|
15
17
|
description
|
16
18
|
|
17
19
|
#{@step_keyword} a step
|
20
|
+
# table comment
|
18
21
|
| value1 |
|
22
|
+
# table row comment
|
23
|
+
| value2 |
|
19
24
|
#{@step_keyword} another step
|
20
25
|
|
26
|
+
# scenario comment
|
21
27
|
@scenario_tag
|
22
28
|
#{@scenario_keyword}:
|
23
29
|
|
@@ -30,29 +36,48 @@ describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
|
|
30
36
|
some text
|
31
37
|
\"\"\"
|
32
38
|
|
39
|
+
# outline comment
|
33
40
|
@outline_tag
|
34
41
|
#{@outline_keyword}:
|
35
42
|
|
36
43
|
Outline
|
37
44
|
description
|
38
45
|
|
46
|
+
# step comment
|
39
47
|
#{@step_keyword} a step
|
48
|
+
# table comment
|
40
49
|
| value2 |
|
50
|
+
# step comment
|
41
51
|
#{@step_keyword} another step
|
52
|
+
# doc string comment
|
42
53
|
\"\"\"
|
43
54
|
some text
|
44
55
|
\"\"\"
|
45
56
|
|
57
|
+
# example comment
|
46
58
|
@example_tag
|
47
59
|
#{@example_keyword}:
|
48
60
|
|
49
61
|
Example
|
50
62
|
description
|
51
63
|
|
64
|
+
# row comment
|
52
65
|
| param |
|
53
|
-
| value |
|
54
|
-
|
66
|
+
| value |
|
67
|
+
# final comment" }
|
68
|
+
let(:feature_file) { path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
69
|
+
File.open(path, "w") { |file| file.puts source_text }
|
70
|
+
|
71
|
+
CukeModeler::FeatureFile.new(path) }
|
72
|
+
let(:feature) { feature_file.feature }
|
73
|
+
|
55
74
|
|
75
|
+
it "does not store parsing data for a feature file's children" do
|
76
|
+
model = feature_file
|
77
|
+
|
78
|
+
expect(model.parsing_data[:comments]).to be_nil
|
79
|
+
expect(model.parsing_data[:feature]).to be_nil
|
80
|
+
end
|
56
81
|
|
57
82
|
it "does not store parsing data for a feature's children" do
|
58
83
|
model = feature
|
@@ -46,6 +46,7 @@ describe 'Parsing, Integration' do
|
|
46
46
|
expect { nodule.parse_text(5) }.to raise_error(ArgumentError, /Fixnum/)
|
47
47
|
end
|
48
48
|
|
49
|
+
# todo - Stop doing this. Just return a feature file rooted AST.
|
49
50
|
it 'returns an Array' do
|
50
51
|
result = nodule.parse_text("#{@feature_keyword}:")
|
51
52
|
expect(result).to be_a(Array)
|