cuke_modeler 2.0.0 → 3.3.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 +4 -4
- data/CHANGELOG.md +59 -2
- data/README.md +14 -16
- data/cuke_modeler.gemspec +12 -9
- data/lib/cuke_modeler.rb +1 -0
- data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +104 -69
- data/lib/cuke_modeler/containing.rb +15 -5
- data/lib/cuke_modeler/models/background.rb +1 -1
- data/lib/cuke_modeler/models/cell.rb +1 -1
- data/lib/cuke_modeler/models/comment.rb +1 -1
- data/lib/cuke_modeler/models/directory.rb +2 -2
- data/lib/cuke_modeler/models/doc_string.rb +1 -1
- data/lib/cuke_modeler/models/example.rb +1 -1
- data/lib/cuke_modeler/models/feature.rb +16 -5
- data/lib/cuke_modeler/models/feature_file.rb +2 -2
- data/lib/cuke_modeler/models/outline.rb +1 -1
- data/lib/cuke_modeler/models/row.rb +1 -1
- data/lib/cuke_modeler/models/rule.rb +99 -0
- 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/parsing.rb +89 -110
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
- data/testing/cucumber/features/modeling/feature_output.feature +45 -23
- data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
- data/testing/cucumber/features/modeling/rule_output.feature +111 -0
- metadata +39 -140
- data/.gitignore +0 -18
- data/.simplecov +0 -7
- data/.travis.yml +0 -63
- data/Gemfile +0 -37
- data/Rakefile +0 -73
- data/appveyor.yml +0 -61
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
- data/testing/cucumber/step_definitions/action_steps.rb +0 -13
- data/testing/cucumber/step_definitions/background_steps.rb +0 -1
- data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
- data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
- data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
- data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
- data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
- data/testing/cucumber/step_definitions/step_steps.rb +0 -3
- data/testing/cucumber/step_definitions/table_steps.rb +0 -1
- data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
- data/testing/cucumber/support/env.rb +0 -30
- data/testing/dialect_helper.rb +0 -48
- data/testing/file_helper.rb +0 -47
- data/testing/gemfiles/gherkin2.gemfile +0 -33
- data/testing/gemfiles/gherkin3.gemfile +0 -26
- data/testing/gemfiles/gherkin4.gemfile +0 -27
- data/testing/gemfiles/gherkin5.gemfile +0 -27
- data/testing/gemfiles/gherkin6.gemfile +0 -10
- data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
- data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -442
- data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -335
- data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -177
- data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
- data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -402
- data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -741
- data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -272
- data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -650
- data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
- data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -624
- data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -291
- data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -479
- data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -569
- data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -337
- data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -259
- data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -122
- data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
- data/testing/rspec/spec/spec_helper.rb +0 -136
- data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
- data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
- data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
- data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
- data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
- data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
- data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
- data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
- data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
- data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
- data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
- data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
- data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
- data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
- data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
- data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
- data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
- data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
- data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
- data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
- data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
- data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
- data/testing/test_languages.json +0 -45
- data/todo.txt +0 -25
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'Gherkin4Adapter, Integration', :gherkin4_5 => true do
|
|
5
|
-
|
|
6
|
-
let(:clazz) { CukeModeler::Gherkin4Adapter }
|
|
7
|
-
let(:adapter) { clazz.new }
|
|
8
|
-
let(:source_text) { "# feature comment
|
|
9
|
-
@tag1 @tag2 @tag3
|
|
10
|
-
#{FEATURE_KEYWORD}: A feature with everything it could have
|
|
11
|
-
|
|
12
|
-
Including a description
|
|
13
|
-
and then some.
|
|
14
|
-
|
|
15
|
-
# background comment
|
|
16
|
-
#{BACKGROUND_KEYWORD}:
|
|
17
|
-
|
|
18
|
-
Background
|
|
19
|
-
description
|
|
20
|
-
|
|
21
|
-
#{STEP_KEYWORD} a step
|
|
22
|
-
# table comment
|
|
23
|
-
| value1 |
|
|
24
|
-
# table row comment
|
|
25
|
-
| value2 |
|
|
26
|
-
#{STEP_KEYWORD} another step
|
|
27
|
-
|
|
28
|
-
# scenario comment
|
|
29
|
-
@scenario_tag
|
|
30
|
-
#{SCENARIO_KEYWORD}:
|
|
31
|
-
|
|
32
|
-
Scenario
|
|
33
|
-
description
|
|
34
|
-
|
|
35
|
-
#{STEP_KEYWORD} a step
|
|
36
|
-
#{STEP_KEYWORD} another step
|
|
37
|
-
\"\"\"
|
|
38
|
-
some text
|
|
39
|
-
\"\"\"
|
|
40
|
-
|
|
41
|
-
# outline comment
|
|
42
|
-
@outline_tag
|
|
43
|
-
#{OUTLINE_KEYWORD}:
|
|
44
|
-
|
|
45
|
-
Outline
|
|
46
|
-
description
|
|
47
|
-
|
|
48
|
-
# step comment
|
|
49
|
-
#{STEP_KEYWORD} a step
|
|
50
|
-
# table comment
|
|
51
|
-
| value2 |
|
|
52
|
-
# step comment
|
|
53
|
-
#{STEP_KEYWORD} another step
|
|
54
|
-
# doc string comment
|
|
55
|
-
\"\"\"
|
|
56
|
-
some text
|
|
57
|
-
\"\"\"
|
|
58
|
-
|
|
59
|
-
# example comment
|
|
60
|
-
@example_tag
|
|
61
|
-
#{EXAMPLE_KEYWORD}:
|
|
62
|
-
|
|
63
|
-
Example
|
|
64
|
-
description
|
|
65
|
-
|
|
66
|
-
# row comment
|
|
67
|
-
| param |
|
|
68
|
-
| value |
|
|
69
|
-
# final comment" }
|
|
70
|
-
let(:feature_file_model) { test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'adapter_test_file')
|
|
71
|
-
CukeModeler::FeatureFile.new(test_file_path) }
|
|
72
|
-
let(:feature_model) { feature_file_model.feature }
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
it "does not store parsing data for a feature file's children" do
|
|
76
|
-
model = feature_file_model
|
|
77
|
-
|
|
78
|
-
expect(model.parsing_data[:comments]).to be_nil
|
|
79
|
-
expect(model.parsing_data[:feature]).to be_nil
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "does not store parsing data for a feature's children" do
|
|
83
|
-
model = feature_model
|
|
84
|
-
|
|
85
|
-
expect(model.parsing_data[:tags]).to be_nil
|
|
86
|
-
expect(model.parsing_data[:children]).to be_nil
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "does not store parsing data for a background's children" do
|
|
90
|
-
model = feature_model.background
|
|
91
|
-
|
|
92
|
-
expect(model.parsing_data[:steps]).to be_nil
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "does not store parsing data for a scenario's children" do
|
|
96
|
-
model = feature_model.scenarios.first
|
|
97
|
-
|
|
98
|
-
expect(model.parsing_data[:tags]).to be_nil
|
|
99
|
-
expect(model.parsing_data[:steps]).to be_nil
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it "does not store parsing data for an outline's children" do
|
|
103
|
-
model = feature_model.outlines.first
|
|
104
|
-
|
|
105
|
-
expect(model.parsing_data[:tags]).to be_nil
|
|
106
|
-
expect(model.parsing_data[:steps]).to be_nil
|
|
107
|
-
expect(model.parsing_data[:examples]).to be_nil
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "does not store parsing data for an example's children" do
|
|
111
|
-
model = feature_model.outlines.first.examples.first
|
|
112
|
-
|
|
113
|
-
expect(model.parsing_data[:tags]).to be_nil
|
|
114
|
-
expect(model.parsing_data[:tableHeader]).to be_nil
|
|
115
|
-
expect(model.parsing_data[:tableBody]).to be_nil
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "does not store parsing data for an example row's children" do
|
|
119
|
-
model = feature_model.outlines.first.examples.first.rows.first
|
|
120
|
-
|
|
121
|
-
expect(model.parsing_data[:cells]).to be_nil
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it "does not store parsing data for a step's children, table" do
|
|
125
|
-
model = feature_model.outlines.first.steps.first
|
|
126
|
-
|
|
127
|
-
expect(model.parsing_data[:argument]).to be_nil
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "does not store parsing data for a step's children, doc string" do
|
|
131
|
-
model = feature_model.outlines.first.steps.last
|
|
132
|
-
|
|
133
|
-
expect(model.parsing_data[:argument]).to be_nil
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it "does not store parsing data for a table's children" do
|
|
137
|
-
model = feature_model.outlines.first.steps.first.block
|
|
138
|
-
|
|
139
|
-
expect(model.parsing_data[:rows]).to be_nil
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "does not store parsing data for a table row's children" do
|
|
143
|
-
model = feature_model.outlines.first.steps.first.block.rows.first
|
|
144
|
-
|
|
145
|
-
expect(model.parsing_data[:cells]).to be_nil
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
describe 'stuff that is in no way part of the public API and entirely subject to change' do
|
|
150
|
-
|
|
151
|
-
it 'provides a useful explosion message if it encounters an entirely new type of test' do
|
|
152
|
-
partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :children => [{:type => :some_unknown_type}]}
|
|
153
|
-
|
|
154
|
-
expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it 'provides a useful explosion message if it encounters an entirely new type of step block' do
|
|
158
|
-
partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :children => [{:type => :Scenario, :tags => [], :location => {:line => 1, :column => 1}, :steps => [{:type => :Step, :location => {:line => 1, :column => 1}, :argument => {:type => :some_unknown_type, :location => {:line => 1, :column => 1}, :content => ""}}]}]}
|
|
159
|
-
|
|
160
|
-
expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
end
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'Gherkin6Adapter, Integration', :gherkin6 => true do
|
|
5
|
-
|
|
6
|
-
let(:clazz) { CukeModeler::Gherkin6Adapter }
|
|
7
|
-
let(:adapter) { clazz.new }
|
|
8
|
-
let(:source_text) { "# feature comment
|
|
9
|
-
@tag1 @tag2 @tag3
|
|
10
|
-
#{FEATURE_KEYWORD}: A feature with everything it could have
|
|
11
|
-
|
|
12
|
-
Including a description
|
|
13
|
-
and then some.
|
|
14
|
-
|
|
15
|
-
# background comment
|
|
16
|
-
#{BACKGROUND_KEYWORD}:
|
|
17
|
-
|
|
18
|
-
Background
|
|
19
|
-
description
|
|
20
|
-
|
|
21
|
-
#{STEP_KEYWORD} a step
|
|
22
|
-
# table comment
|
|
23
|
-
| value1 |
|
|
24
|
-
# table row comment
|
|
25
|
-
| value2 |
|
|
26
|
-
#{STEP_KEYWORD} another step
|
|
27
|
-
|
|
28
|
-
# scenario comment
|
|
29
|
-
@scenario_tag
|
|
30
|
-
#{SCENARIO_KEYWORD}:
|
|
31
|
-
|
|
32
|
-
Scenario
|
|
33
|
-
description
|
|
34
|
-
|
|
35
|
-
#{STEP_KEYWORD} a step
|
|
36
|
-
#{STEP_KEYWORD} another step
|
|
37
|
-
\"\"\"
|
|
38
|
-
some text
|
|
39
|
-
\"\"\"
|
|
40
|
-
|
|
41
|
-
# outline comment
|
|
42
|
-
@outline_tag
|
|
43
|
-
#{OUTLINE_KEYWORD}:
|
|
44
|
-
|
|
45
|
-
Outline
|
|
46
|
-
description
|
|
47
|
-
|
|
48
|
-
# step comment
|
|
49
|
-
#{STEP_KEYWORD} a step
|
|
50
|
-
# table comment
|
|
51
|
-
| value2 |
|
|
52
|
-
# step comment
|
|
53
|
-
#{STEP_KEYWORD} another step
|
|
54
|
-
# doc string comment
|
|
55
|
-
\"\"\"
|
|
56
|
-
some text
|
|
57
|
-
\"\"\"
|
|
58
|
-
|
|
59
|
-
# example comment
|
|
60
|
-
@example_tag
|
|
61
|
-
#{EXAMPLE_KEYWORD}:
|
|
62
|
-
|
|
63
|
-
Example
|
|
64
|
-
description
|
|
65
|
-
|
|
66
|
-
# row comment
|
|
67
|
-
| param |
|
|
68
|
-
| value |
|
|
69
|
-
# final comment" }
|
|
70
|
-
let(:feature_file_model) { test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'adapter_test_file')
|
|
71
|
-
CukeModeler::FeatureFile.new(test_file_path) }
|
|
72
|
-
let(:feature_model) { feature_file_model.feature }
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
it "does not store parsing data for a feature file's children" do
|
|
76
|
-
model = feature_file_model
|
|
77
|
-
|
|
78
|
-
expect(model.parsing_data[:comments]).to be_nil
|
|
79
|
-
expect(model.parsing_data[:feature]).to be_nil
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "does not store parsing data for a feature's children" do
|
|
83
|
-
model = feature_model
|
|
84
|
-
|
|
85
|
-
expect(model.parsing_data[:tags]).to be_nil
|
|
86
|
-
expect(model.parsing_data[:children]).to be_nil
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "does not store parsing data for a background's children" do
|
|
90
|
-
model = feature_model.background
|
|
91
|
-
|
|
92
|
-
expect(model.parsing_data[:background][:steps]).to be_nil
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "does not store parsing data for a scenario's children" do
|
|
96
|
-
model = feature_model.scenarios.first
|
|
97
|
-
|
|
98
|
-
expect(model.parsing_data[:scenario][:tags]).to be_nil
|
|
99
|
-
expect(model.parsing_data[:scenario][:steps]).to be_nil
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it "does not store parsing data for an outline's children" do
|
|
103
|
-
model = feature_model.outlines.first
|
|
104
|
-
|
|
105
|
-
expect(model.parsing_data[:scenario][:tags]).to be_nil
|
|
106
|
-
expect(model.parsing_data[:scenario][:steps]).to be_nil
|
|
107
|
-
expect(model.parsing_data[:scenario][:examples]).to be_nil
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "does not store parsing data for an example's children" do
|
|
111
|
-
model = feature_model.outlines.first.examples.first
|
|
112
|
-
|
|
113
|
-
expect(model.parsing_data[:tags]).to be_nil
|
|
114
|
-
expect(model.parsing_data[:table_header]).to be_nil
|
|
115
|
-
expect(model.parsing_data[:table_body]).to be_nil
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "does not store parsing data for an example row's children" do
|
|
119
|
-
model = feature_model.outlines.first.examples.first.rows.first
|
|
120
|
-
|
|
121
|
-
expect(model.parsing_data[:cells]).to be_nil
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it "does not store parsing data for a step's children, table" do
|
|
125
|
-
model = feature_model.outlines.first.steps.first
|
|
126
|
-
|
|
127
|
-
expect(model.parsing_data[:data_table]).to be_nil
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "does not store parsing data for a step's children, doc string" do
|
|
131
|
-
model = feature_model.outlines.first.steps.last
|
|
132
|
-
|
|
133
|
-
expect(model.parsing_data[:doc_string]).to be_nil
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it "does not store parsing data for a table's children" do
|
|
137
|
-
model = feature_model.outlines.first.steps.first.block
|
|
138
|
-
|
|
139
|
-
expect(model.parsing_data[:rows]).to be_nil
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "does not store parsing data for a table row's children" do
|
|
143
|
-
model = feature_model.outlines.first.steps.first.block.rows.first
|
|
144
|
-
|
|
145
|
-
expect(model.parsing_data[:cells]).to be_nil
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
describe 'stuff that is in no way part of the public API and entirely subject to change' do
|
|
150
|
-
|
|
151
|
-
it 'provides a useful explosion message if it encounters an entirely new type of test' do
|
|
152
|
-
partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :children => [{:some_unknown_type => {}}]}
|
|
153
|
-
|
|
154
|
-
expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
# TODO: no longer possible in G6?
|
|
158
|
-
# it 'provides a useful explosion message if it encounters an entirely new type of step block' do
|
|
159
|
-
# partial_feature_ast = {:type => :Feature, :location => {:line => 1, :column => 1}, :children => [{:type => :Scenario, :tags => [], :location => {:line => 1, :column => 1}, :steps => [{:type => :Step, :location => {:line => 1, :column => 1}, :argument => {:type => :some_unknown_type, :location => {:line => 1, :column => 1}, :content => ""}}]}]}
|
|
160
|
-
#
|
|
161
|
-
# expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
|
|
162
|
-
# end
|
|
163
|
-
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
end
|
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../../spec_helper"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe 'Background, Integration' do
|
|
5
|
-
|
|
6
|
-
let(:clazz) { CukeModeler::Background }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
describe 'common behavior' do
|
|
10
|
-
|
|
11
|
-
it_should_behave_like 'a model, integration'
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe 'unique behavior' do
|
|
16
|
-
|
|
17
|
-
it 'can be instantiated with the minimum viable Gherkin' do
|
|
18
|
-
source = "#{BACKGROUND_KEYWORD}:"
|
|
19
|
-
|
|
20
|
-
expect { clazz.new(source) }.to_not raise_error
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'can parse text that uses a non-default dialect' do
|
|
24
|
-
original_dialect = CukeModeler::Parsing.dialect
|
|
25
|
-
CukeModeler::Parsing.dialect = 'en-au'
|
|
26
|
-
|
|
27
|
-
begin
|
|
28
|
-
source_text = 'First off: Background name'
|
|
29
|
-
|
|
30
|
-
expect { @model = clazz.new(source_text) }.to_not raise_error
|
|
31
|
-
|
|
32
|
-
# Sanity check in case modeling failed in a non-explosive manner
|
|
33
|
-
expect(@model.name).to eq('Background name')
|
|
34
|
-
ensure
|
|
35
|
-
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
|
36
|
-
CukeModeler::Parsing.dialect = original_dialect
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
|
|
41
|
-
background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
|
|
42
|
-
data = background.parsing_data
|
|
43
|
-
|
|
44
|
-
expect(data.keys).to match_array([:background, :rule, :scenario])
|
|
45
|
-
expect(data[:background][:name]).to eq('test background')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
|
|
49
|
-
background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
|
|
50
|
-
data = background.parsing_data
|
|
51
|
-
|
|
52
|
-
expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
|
|
53
|
-
expect(data[:type]).to eq(:Background)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
|
57
|
-
background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
|
|
58
|
-
data = background.parsing_data
|
|
59
|
-
|
|
60
|
-
expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
|
|
61
|
-
expect(data[:type]).to eq(:Background)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
|
65
|
-
background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
|
|
66
|
-
data = background.parsing_data
|
|
67
|
-
|
|
68
|
-
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'steps', 'type'])
|
|
69
|
-
expect(data['keyword']).to eq('Background')
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'provides a descriptive filename when being parsed from stand alone text' do
|
|
73
|
-
source = "bad background text \n #{BACKGROUND_KEYWORD}:\n #{STEP_KEYWORD} a step\n @foo "
|
|
74
|
-
|
|
75
|
-
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_background\.feature'/)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it 'properly sets its child models' do
|
|
79
|
-
source = "#{BACKGROUND_KEYWORD}: Test background
|
|
80
|
-
#{STEP_KEYWORD} a step"
|
|
81
|
-
|
|
82
|
-
background = clazz.new(source)
|
|
83
|
-
step = background.steps.first
|
|
84
|
-
|
|
85
|
-
expect(step.parent_model).to equal(background)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
it 'trims whitespace from its source description' do
|
|
89
|
-
source = ["#{BACKGROUND_KEYWORD}:",
|
|
90
|
-
' ',
|
|
91
|
-
' description line 1',
|
|
92
|
-
'',
|
|
93
|
-
' description line 2',
|
|
94
|
-
' description line 3 ',
|
|
95
|
-
'',
|
|
96
|
-
'',
|
|
97
|
-
'',
|
|
98
|
-
" #{STEP_KEYWORD} a step"]
|
|
99
|
-
source = source.join("\n")
|
|
100
|
-
|
|
101
|
-
background = clazz.new(source)
|
|
102
|
-
description = background.description.split("\n", -1)
|
|
103
|
-
|
|
104
|
-
expect(description).to eq([' description line 1',
|
|
105
|
-
'',
|
|
106
|
-
'description line 2',
|
|
107
|
-
' description line 3'])
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
describe 'getting ancestors' do
|
|
112
|
-
|
|
113
|
-
before(:each) do
|
|
114
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'background_test_file', :directory => test_directory)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
|
119
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
|
120
|
-
|
|
121
|
-
#{BACKGROUND_KEYWORD}: Test background
|
|
122
|
-
#{STEP_KEYWORD} a step"
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
|
126
|
-
let(:background_model) { directory_model.feature_files.first.feature.background }
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
it 'can get its directory' do
|
|
130
|
-
ancestor = background_model.get_ancestor(:directory)
|
|
131
|
-
|
|
132
|
-
expect(ancestor).to equal(directory_model)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it 'can get its feature file' do
|
|
136
|
-
ancestor = background_model.get_ancestor(:feature_file)
|
|
137
|
-
|
|
138
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it 'can get its feature' do
|
|
142
|
-
ancestor = background_model.get_ancestor(:feature)
|
|
143
|
-
|
|
144
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
|
148
|
-
ancestor = background_model.get_ancestor(:example)
|
|
149
|
-
|
|
150
|
-
expect(ancestor).to be_nil
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
describe 'model population' do
|
|
157
|
-
|
|
158
|
-
context 'from source text' do
|
|
159
|
-
|
|
160
|
-
let(:source_text) { "#{BACKGROUND_KEYWORD}:" }
|
|
161
|
-
let(:background) { clazz.new(source_text) }
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
it "models the background's keyword" do
|
|
165
|
-
expect(background.keyword).to eq("#{BACKGROUND_KEYWORD}")
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it "models the background's source line" do
|
|
169
|
-
source_text = "#{FEATURE_KEYWORD}:
|
|
170
|
-
|
|
171
|
-
#{BACKGROUND_KEYWORD}: foo
|
|
172
|
-
#{STEP_KEYWORD} step"
|
|
173
|
-
background = CukeModeler::Feature.new(source_text).background
|
|
174
|
-
|
|
175
|
-
expect(background.source_line).to eq(3)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
context 'a filled background' do
|
|
179
|
-
|
|
180
|
-
let(:source_text) { "#{BACKGROUND_KEYWORD}: Background name
|
|
181
|
-
|
|
182
|
-
Background description.
|
|
183
|
-
|
|
184
|
-
Some more.
|
|
185
|
-
Even more.
|
|
186
|
-
|
|
187
|
-
#{STEP_KEYWORD} a step
|
|
188
|
-
#{STEP_KEYWORD} another step" }
|
|
189
|
-
let(:background) { clazz.new(source_text) }
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
it "models the background's name" do
|
|
193
|
-
expect(background.name).to eq('Background name')
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
it "models the background's description" do
|
|
197
|
-
description = background.description.split("\n", -1)
|
|
198
|
-
|
|
199
|
-
expect(description).to eq([' Background description.',
|
|
200
|
-
'',
|
|
201
|
-
'Some more.',
|
|
202
|
-
' Even more.'])
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
it "models the background's steps" do
|
|
206
|
-
step_names = background.steps.collect { |step| step.text }
|
|
207
|
-
|
|
208
|
-
expect(step_names).to eq(['a step', 'another step'])
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
context 'an empty background' do
|
|
214
|
-
|
|
215
|
-
let(:source_text) { "#{BACKGROUND_KEYWORD}:" }
|
|
216
|
-
let(:background) { clazz.new(source_text) }
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
it "models the background's name" do
|
|
220
|
-
expect(background.name).to eq('')
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
it "models the background's description" do
|
|
224
|
-
expect(background.description).to eq('')
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it "models the background's steps" do
|
|
228
|
-
expect(background.steps).to eq([])
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
describe 'comparison' do
|
|
239
|
-
|
|
240
|
-
it 'is equal to a background with the same steps' do
|
|
241
|
-
source = "#{BACKGROUND_KEYWORD}:
|
|
242
|
-
#{STEP_KEYWORD} step 1
|
|
243
|
-
#{STEP_KEYWORD} step 2"
|
|
244
|
-
background_1 = clazz.new(source)
|
|
245
|
-
|
|
246
|
-
source = "#{BACKGROUND_KEYWORD}:
|
|
247
|
-
#{STEP_KEYWORD} step 1
|
|
248
|
-
#{STEP_KEYWORD} step 2"
|
|
249
|
-
background_2 = clazz.new(source)
|
|
250
|
-
|
|
251
|
-
source = "#{BACKGROUND_KEYWORD}:
|
|
252
|
-
#{STEP_KEYWORD} step 2
|
|
253
|
-
#{STEP_KEYWORD} step 1"
|
|
254
|
-
background_3 = clazz.new(source)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
expect(background_1).to eq(background_2)
|
|
258
|
-
expect(background_1).to_not eq(background_3)
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
it 'is equal to a scenario with the same steps' do
|
|
262
|
-
source = "#{BACKGROUND_KEYWORD}:
|
|
263
|
-
#{STEP_KEYWORD} step 1
|
|
264
|
-
#{STEP_KEYWORD} step 2"
|
|
265
|
-
background = clazz.new(source)
|
|
266
|
-
|
|
267
|
-
source = "#{SCENARIO_KEYWORD}:
|
|
268
|
-
#{STEP_KEYWORD} step 1
|
|
269
|
-
#{STEP_KEYWORD} step 2"
|
|
270
|
-
scenario_1 = CukeModeler::Scenario.new(source)
|
|
271
|
-
|
|
272
|
-
source = "#{SCENARIO_KEYWORD}:
|
|
273
|
-
#{STEP_KEYWORD} step 2
|
|
274
|
-
#{STEP_KEYWORD} step 1"
|
|
275
|
-
scenario_2 = CukeModeler::Scenario.new(source)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
expect(background).to eq(scenario_1)
|
|
279
|
-
expect(background).to_not eq(scenario_2)
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
it 'is equal to an outline with the same steps' do
|
|
283
|
-
source = "#{BACKGROUND_KEYWORD}:
|
|
284
|
-
#{STEP_KEYWORD} step 1
|
|
285
|
-
#{STEP_KEYWORD} step 2"
|
|
286
|
-
background = clazz.new(source)
|
|
287
|
-
|
|
288
|
-
source = "#{OUTLINE_KEYWORD}:
|
|
289
|
-
#{STEP_KEYWORD} step 1
|
|
290
|
-
#{STEP_KEYWORD} step 2
|
|
291
|
-
#{EXAMPLE_KEYWORD}:
|
|
292
|
-
| param |
|
|
293
|
-
| value |"
|
|
294
|
-
outline_1 = CukeModeler::Outline.new(source)
|
|
295
|
-
|
|
296
|
-
source = "#{OUTLINE_KEYWORD}:
|
|
297
|
-
#{STEP_KEYWORD} step 2
|
|
298
|
-
#{STEP_KEYWORD} step 1
|
|
299
|
-
#{EXAMPLE_KEYWORD}:
|
|
300
|
-
| param |
|
|
301
|
-
| value |"
|
|
302
|
-
outline_2 = CukeModeler::Outline.new(source)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
expect(background).to eq(outline_1)
|
|
306
|
-
expect(background).to_not eq(outline_2)
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
describe 'background output' do
|
|
313
|
-
|
|
314
|
-
it 'can be remade from its own output' do
|
|
315
|
-
source = "#{BACKGROUND_KEYWORD}: A background with everything it could have
|
|
316
|
-
|
|
317
|
-
Including a description
|
|
318
|
-
and then some.
|
|
319
|
-
|
|
320
|
-
#{STEP_KEYWORD} a step
|
|
321
|
-
| value |
|
|
322
|
-
#{STEP_KEYWORD} another step
|
|
323
|
-
\"\"\"
|
|
324
|
-
some string
|
|
325
|
-
\"\"\""
|
|
326
|
-
background = clazz.new(source)
|
|
327
|
-
|
|
328
|
-
background_output = background.to_s
|
|
329
|
-
remade_background_output = clazz.new(background_output).to_s
|
|
330
|
-
|
|
331
|
-
expect(remade_background_output).to eq(background_output)
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
context 'from source text' do
|
|
336
|
-
|
|
337
|
-
it 'can output an empty background' do
|
|
338
|
-
source = ["#{BACKGROUND_KEYWORD}:"]
|
|
339
|
-
source = source.join("\n")
|
|
340
|
-
background = clazz.new(source)
|
|
341
|
-
|
|
342
|
-
background_output = background.to_s.split("\n", -1)
|
|
343
|
-
|
|
344
|
-
expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:"])
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
it 'can output a background that has a name' do
|
|
348
|
-
source = ["#{BACKGROUND_KEYWORD}: test background"]
|
|
349
|
-
source = source.join("\n")
|
|
350
|
-
background = clazz.new(source)
|
|
351
|
-
|
|
352
|
-
background_output = background.to_s.split("\n", -1)
|
|
353
|
-
|
|
354
|
-
expect(background_output).to eq(["#{BACKGROUND_KEYWORD}: test background"])
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
it 'can output a background that has a description' do
|
|
358
|
-
source = ["#{BACKGROUND_KEYWORD}:",
|
|
359
|
-
'Some description.',
|
|
360
|
-
'Some more description.']
|
|
361
|
-
source = source.join("\n")
|
|
362
|
-
background = clazz.new(source)
|
|
363
|
-
|
|
364
|
-
background_output = background.to_s.split("\n", -1)
|
|
365
|
-
|
|
366
|
-
expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:",
|
|
367
|
-
'',
|
|
368
|
-
'Some description.',
|
|
369
|
-
'Some more description.'])
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
it 'can output a background that has steps' do
|
|
373
|
-
source = ["#{BACKGROUND_KEYWORD}:",
|
|
374
|
-
"#{STEP_KEYWORD} a step",
|
|
375
|
-
'|value|',
|
|
376
|
-
"#{STEP_KEYWORD} another step",
|
|
377
|
-
'"""',
|
|
378
|
-
'some string',
|
|
379
|
-
'"""']
|
|
380
|
-
source = source.join("\n")
|
|
381
|
-
background = clazz.new(source)
|
|
382
|
-
|
|
383
|
-
background_output = background.to_s.split("\n", -1)
|
|
384
|
-
|
|
385
|
-
expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:",
|
|
386
|
-
" #{STEP_KEYWORD} a step",
|
|
387
|
-
' | value |',
|
|
388
|
-
" #{STEP_KEYWORD} another step",
|
|
389
|
-
' """',
|
|
390
|
-
' some string',
|
|
391
|
-
' """'])
|
|
392
|
-
end
|
|
393
|
-
|
|
394
|
-
it 'can output a background that has everything' do
|
|
395
|
-
source = ["#{BACKGROUND_KEYWORD}: A background with everything it could have",
|
|
396
|
-
'Including a description',
|
|
397
|
-
'and then some.',
|
|
398
|
-
"#{STEP_KEYWORD} a step",
|
|
399
|
-
'|value|',
|
|
400
|
-
"#{STEP_KEYWORD} another step",
|
|
401
|
-
'"""',
|
|
402
|
-
'some string',
|
|
403
|
-
'"""']
|
|
404
|
-
source = source.join("\n")
|
|
405
|
-
background = clazz.new(source)
|
|
406
|
-
|
|
407
|
-
background_output = background.to_s.split("\n", -1)
|
|
408
|
-
|
|
409
|
-
expect(background_output).to eq(["#{BACKGROUND_KEYWORD}: A background with everything it could have",
|
|
410
|
-
'',
|
|
411
|
-
'Including a description',
|
|
412
|
-
'and then some.',
|
|
413
|
-
'',
|
|
414
|
-
" #{STEP_KEYWORD} a step",
|
|
415
|
-
' | value |',
|
|
416
|
-
" #{STEP_KEYWORD} another step",
|
|
417
|
-
' """',
|
|
418
|
-
' some string',
|
|
419
|
-
' """'])
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
end
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
context 'from abstract instantiation' do
|
|
426
|
-
|
|
427
|
-
let(:background) { clazz.new }
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
it 'can output a background that has only steps' do
|
|
431
|
-
background.steps = [CukeModeler::Step.new]
|
|
432
|
-
|
|
433
|
-
expect { background.to_s }.to_not raise_error
|
|
434
|
-
end
|
|
435
|
-
|
|
436
|
-
end
|
|
437
|
-
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
end
|