cuke_modeler 1.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +329 -0
- data/LICENSE.txt +1 -1
- data/README.md +25 -18
- data/cuke_modeler.gemspec +15 -9
- 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_6_adapter.rb → gherkin_9_adapter.rb} +75 -64
- data/lib/cuke_modeler/containing.rb +16 -0
- data/lib/cuke_modeler/described.rb +1 -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 +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 +1 -1
- 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/scenario.rb +1 -1
- data/lib/cuke_modeler/models/step.rb +32 -3
- data/lib/cuke_modeler/models/table.rb +1 -1
- data/lib/cuke_modeler/models/tag.rb +1 -1
- 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 +88 -92
- 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
- metadata +55 -142
- data/.gitignore +0 -18
- data/.simplecov +0 -7
- data/.travis.yml +0 -54
- data/Gemfile +0 -36
- data/History.md +0 -191
- data/Rakefile +0 -63
- data/appveyor.yml +0 -43
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -273
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -296
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -308
- 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 -44
- 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 -173
- 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 -32
- data/testing/gemfiles/gherkin3.gemfile +0 -26
- data/testing/gemfiles/gherkin4.gemfile +0 -27
- data/testing/gemfiles/gherkin5.gemfile +0 -26
- data/testing/gemfiles/gherkin6.gemfile +0 -10
- data/testing/rspec/spec/integration/background_integration_spec.rb +0 -442
- data/testing/rspec/spec/integration/cell_integration_spec.rb +0 -335
- data/testing/rspec/spec/integration/comment_integration_spec.rb +0 -177
- data/testing/rspec/spec/integration/directory_integration_spec.rb +0 -218
- data/testing/rspec/spec/integration/doc_string_integration_spec.rb +0 -402
- data/testing/rspec/spec/integration/example_integration_spec.rb +0 -741
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +0 -272
- data/testing/rspec/spec/integration/feature_integration_spec.rb +0 -650
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +0 -165
- data/testing/rspec/spec/integration/gherkin_6_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/model_integration_spec.rb +0 -15
- data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
- data/testing/rspec/spec/integration/outline_integration_spec.rb +0 -624
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -117
- data/testing/rspec/spec/integration/row_integration_spec.rb +0 -291
- data/testing/rspec/spec/integration/scenario_integration_spec.rb +0 -479
- data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
- data/testing/rspec/spec/integration/step_integration_spec.rb +0 -475
- data/testing/rspec/spec/integration/table_integration_spec.rb +0 -337
- data/testing/rspec/spec/integration/tag_integration_spec.rb +0 -259
- data/testing/rspec/spec/spec_helper.rb +0 -122
- data/testing/rspec/spec/unit/background_unit_spec.rb +0 -83
- data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -127
- data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -100
- data/testing/rspec/spec/unit/example_unit_spec.rb +0 -133
- data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -157
- data/testing/rspec/spec/unit/model_unit_spec.rb +0 -15
- 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/outline_unit_spec.rb +0 -117
- 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/row_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -86
- 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 -25
- 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/step_unit_spec.rb +0 -109
- data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/table_unit_spec.rb +0 -77
- data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
- data/testing/test_languages.json +0 -45
- data/todo.txt +0 -24
@@ -1,117 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Parsing, Integration' do
|
5
|
-
|
6
|
-
let(:nodule) { CukeModeler::Parsing }
|
7
|
-
|
8
|
-
|
9
|
-
describe 'unique behavior' do
|
10
|
-
|
11
|
-
it 'will complain if using an unknown version of `gherkin`' do
|
12
|
-
skip('finish me')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'loads the correct dialects based on the version of Gherkin used', :gherkin6 => true do
|
16
|
-
expect(nodule.dialects).to equal(Gherkin::DIALECTS)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'loads the correct dialects based on the version of Gherkin used', :gherkin3 => true, :gherkin4_5 => true do
|
20
|
-
expect(nodule.dialects).to equal(Gherkin::DIALECTS)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'loads the correct dialects based on the version of Gherkin used', :gherkin2 => true do
|
24
|
-
expect(nodule.dialects).to equal(Gherkin::I18n::LANGUAGES)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'can parse text that uses a non-default dialect' do
|
28
|
-
source_text = "# language: en-au
|
29
|
-
Pretty much:
|
30
|
-
|
31
|
-
First off:
|
32
|
-
Y'know foo
|
33
|
-
|
34
|
-
Awww, look mate:
|
35
|
-
It's just unbelievable that zip
|
36
|
-
But at the end of the day I reckon bar
|
37
|
-
|
38
|
-
Reckon it's like:
|
39
|
-
Yeah nah zen
|
40
|
-
Too right baz
|
41
|
-
You'll wanna:
|
42
|
-
| param |
|
43
|
-
| value |"
|
44
|
-
|
45
|
-
expect { nodule.parse_text(source_text) }.to_not raise_error
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'raises and error if given something to parse besides a string' do
|
49
|
-
expect { nodule.parse_text(5) }.to raise_error(ArgumentError, /Text to parse must be a String but got/)
|
50
|
-
expect { nodule.parse_text("#{FEATURE_KEYWORD}:") }.to_not raise_error
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'includes the type of object provided when raising an non-string exception' do
|
54
|
-
expect { nodule.parse_text(:not_a_string) }.to raise_error(ArgumentError, /Symbol/)
|
55
|
-
end
|
56
|
-
|
57
|
-
# todo - Stop doing this. Just return a feature file rooted AST. (Will require major version number change)
|
58
|
-
it 'returns an Array' do
|
59
|
-
result = nodule.parse_text("#{FEATURE_KEYWORD}:")
|
60
|
-
expect(result).to be_a(Array)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'raises an error if an error is encountered while parsing text' do
|
64
|
-
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /Error encountered while parsing '.*'/)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'includes the file parsed in the error that it raises' do
|
68
|
-
expect { nodule.parse_text('bad file', 'file foo.txt') }.to raise_error(/'file foo\.txt'/)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'includes the underlying error message in the error that it raises' do
|
72
|
-
begin
|
73
|
-
$old_method = CukeModeler::Parsing.method(:parsing_method)
|
74
|
-
|
75
|
-
# Custom error type in order to ensure that we are throwing the correct thing
|
76
|
-
module CukeModeler
|
77
|
-
class TestError < StandardError
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# Monkey patch the parsing method to throw the error that we need for testing
|
82
|
-
module CukeModeler
|
83
|
-
module Parsing
|
84
|
-
class << self
|
85
|
-
def parsing_method(*args)
|
86
|
-
raise(CukeModeler::TestError, 'something went wrong')
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
expect { nodule.parse_text('bad file') }.to raise_error(/CukeModeler::TestError.*something went wrong/)
|
94
|
-
ensure
|
95
|
-
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
96
|
-
module CukeModeler
|
97
|
-
module Parsing
|
98
|
-
class << self
|
99
|
-
define_method(:parsing_method, $old_method)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'has a default file name if one is not provided' do
|
108
|
-
expect { nodule.parse_text('bad file') }.to raise_error(ArgumentError, /'cuke_modeler_fake_file\.feature'/)
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'uses the given file name if one is provided' do
|
112
|
-
skip('finish me')
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
@@ -1,291 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Row, Integration' do
|
5
|
-
|
6
|
-
let(:clazz) { CukeModeler::Row }
|
7
|
-
|
8
|
-
|
9
|
-
describe 'common behavior' do
|
10
|
-
|
11
|
-
it_should_behave_like 'a model, integration'
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
describe 'unique behavior' do
|
17
|
-
|
18
|
-
it 'can be instantiated with the minimum viable Gherkin' do
|
19
|
-
source = '| a | row |'
|
20
|
-
|
21
|
-
expect { clazz.new(source) }.to_not raise_error
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'can parse text that uses a non-default dialect' do
|
25
|
-
original_dialect = CukeModeler::Parsing.dialect
|
26
|
-
CukeModeler::Parsing.dialect = 'en-au'
|
27
|
-
|
28
|
-
begin
|
29
|
-
source_text = '| a | row |'
|
30
|
-
|
31
|
-
expect { @model = clazz.new(source_text) }.to_not raise_error
|
32
|
-
|
33
|
-
# Sanity check in case modeling failed in a non-explosive manner
|
34
|
-
expect(@model.cells.last.value).to eq('row')
|
35
|
-
ensure
|
36
|
-
# Making sure that our changes don't escape a test and ruin the rest of the suite
|
37
|
-
CukeModeler::Parsing.dialect = original_dialect
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'provides a descriptive filename when being parsed from stand alone text' do
|
42
|
-
source = " |bad |row| text| \n @foo "
|
43
|
-
|
44
|
-
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_row\.feature'/)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
|
48
|
-
example_row = clazz.new("| a | row |")
|
49
|
-
data = example_row.parsing_data
|
50
|
-
|
51
|
-
expect(data.keys).to match_array([:location, :cells])
|
52
|
-
expect(data[:location][:line]).to eq(5)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
|
56
|
-
example_row = clazz.new("| a | row |")
|
57
|
-
data = example_row.parsing_data
|
58
|
-
|
59
|
-
expect(data.keys).to match_array([:type, :location, :cells])
|
60
|
-
expect(data[:type]).to eq(:TableRow)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
64
|
-
example_row = clazz.new("| a | row |")
|
65
|
-
data = example_row.parsing_data
|
66
|
-
|
67
|
-
expect(data.keys).to match_array([:type, :location, :cells])
|
68
|
-
expect(data[:type]).to eq('TableRow')
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
72
|
-
example_row = clazz.new("| a | row |")
|
73
|
-
data = example_row.parsing_data
|
74
|
-
|
75
|
-
expect(data.keys).to match_array(['cells', 'line'])
|
76
|
-
expect(data['line']).to eq(5)
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'properly sets its child models' do
|
80
|
-
source = '| cell 1 | cell 2 |'
|
81
|
-
|
82
|
-
row = clazz.new(source)
|
83
|
-
cell_1 = row.cells.first
|
84
|
-
cell_2 = row.cells.last
|
85
|
-
|
86
|
-
expect(cell_1.parent_model).to equal(row)
|
87
|
-
expect(cell_2.parent_model).to equal(row)
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
describe 'getting ancestors' do
|
92
|
-
|
93
|
-
before(:each) do
|
94
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'row_test_file', :directory => test_directory)
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
99
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
100
|
-
|
101
|
-
#{SCENARIO_KEYWORD}: Test test
|
102
|
-
#{STEP_KEYWORD} a step:
|
103
|
-
| a | table |"
|
104
|
-
}
|
105
|
-
|
106
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
107
|
-
let(:row_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first }
|
108
|
-
|
109
|
-
|
110
|
-
it 'can get its directory' do
|
111
|
-
ancestor = row_model.get_ancestor(:directory)
|
112
|
-
|
113
|
-
expect(ancestor).to equal(directory_model)
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'can get its feature file' do
|
117
|
-
ancestor = row_model.get_ancestor(:feature_file)
|
118
|
-
|
119
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'can get its feature' do
|
123
|
-
ancestor = row_model.get_ancestor(:feature)
|
124
|
-
|
125
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'can get its step' do
|
129
|
-
ancestor = row_model.get_ancestor(:step)
|
130
|
-
|
131
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'can get its table' do
|
135
|
-
ancestor = row_model.get_ancestor(:table)
|
136
|
-
|
137
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block)
|
138
|
-
end
|
139
|
-
|
140
|
-
context 'a row that is part of a scenario' do
|
141
|
-
|
142
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
143
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
144
|
-
|
145
|
-
#{SCENARIO_KEYWORD}: Test test
|
146
|
-
#{STEP_KEYWORD} a step:
|
147
|
-
| a | table |"
|
148
|
-
}
|
149
|
-
|
150
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
151
|
-
let(:row_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first }
|
152
|
-
|
153
|
-
|
154
|
-
it 'can get its scenario' do
|
155
|
-
ancestor = row_model.get_ancestor(:scenario)
|
156
|
-
|
157
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
161
|
-
|
162
|
-
|
163
|
-
context 'a row that is part of a background' do
|
164
|
-
|
165
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
166
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
167
|
-
|
168
|
-
#{BACKGROUND_KEYWORD}: Test background
|
169
|
-
#{STEP_KEYWORD} a step:
|
170
|
-
| a | table |"
|
171
|
-
}
|
172
|
-
|
173
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
174
|
-
let(:row_model) { directory_model.feature_files.first.feature.background.steps.first.block.rows.first }
|
175
|
-
|
176
|
-
|
177
|
-
it 'can get its background' do
|
178
|
-
ancestor = row_model.get_ancestor(:background)
|
179
|
-
|
180
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
|
181
|
-
end
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
context 'a row that is part of an outline' do
|
186
|
-
|
187
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
188
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
189
|
-
|
190
|
-
#{OUTLINE_KEYWORD}: Test outline
|
191
|
-
#{STEP_KEYWORD} a step
|
192
|
-
#{EXAMPLE_KEYWORD}:
|
193
|
-
| param |
|
194
|
-
| value |"
|
195
|
-
}
|
196
|
-
|
197
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
198
|
-
let(:row_model) { directory_model.feature_files.first.feature.tests.first.examples.first.rows.first }
|
199
|
-
|
200
|
-
|
201
|
-
it 'can get its outline' do
|
202
|
-
ancestor = row_model.get_ancestor(:outline)
|
203
|
-
|
204
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'can get its example' do
|
208
|
-
ancestor = row_model.get_ancestor(:example)
|
209
|
-
|
210
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first)
|
211
|
-
end
|
212
|
-
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
216
|
-
ancestor = row_model.get_ancestor(:outline)
|
217
|
-
|
218
|
-
expect(ancestor).to be_nil
|
219
|
-
end
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
|
224
|
-
describe 'model population' do
|
225
|
-
|
226
|
-
context 'from source text' do
|
227
|
-
|
228
|
-
let(:source_text) { '| cell 1 | cell 2 |' }
|
229
|
-
let(:row) { clazz.new(source_text) }
|
230
|
-
|
231
|
-
|
232
|
-
it "models the row's cells" do
|
233
|
-
cell_values = row.cells.collect { |cell| cell.value }
|
234
|
-
|
235
|
-
expect(cell_values).to match_array(['cell 1', 'cell 2'])
|
236
|
-
end
|
237
|
-
|
238
|
-
it "models the row's source line" do
|
239
|
-
source_text = "#{FEATURE_KEYWORD}: Test feature
|
240
|
-
|
241
|
-
#{OUTLINE_KEYWORD}: Test outline
|
242
|
-
#{STEP_KEYWORD} a step
|
243
|
-
#{EXAMPLE_KEYWORD}:
|
244
|
-
| param |
|
245
|
-
| value |"
|
246
|
-
row = CukeModeler::Feature.new(source_text).tests.first.examples.first.rows.first
|
247
|
-
|
248
|
-
expect(row.source_line).to eq(6)
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
|
-
describe 'row output' do
|
257
|
-
|
258
|
-
it 'can be remade from its own output' do
|
259
|
-
source = "| value1 | value2 |"
|
260
|
-
row = clazz.new(source)
|
261
|
-
|
262
|
-
row_output = row.to_s
|
263
|
-
remade_row_output = clazz.new(row_output).to_s
|
264
|
-
|
265
|
-
expect(remade_row_output).to eq(row_output)
|
266
|
-
end
|
267
|
-
|
268
|
-
|
269
|
-
context 'from source text' do
|
270
|
-
|
271
|
-
it 'can output a row' do
|
272
|
-
source = '| some value |'
|
273
|
-
row = clazz.new(source)
|
274
|
-
|
275
|
-
expect(row.to_s).to eq('| some value |')
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'can output a row with multiple cells' do
|
279
|
-
source = '| some value | some other value |'
|
280
|
-
row = clazz.new(source)
|
281
|
-
|
282
|
-
expect(row.to_s).to eq('| some value | some other value |')
|
283
|
-
end
|
284
|
-
|
285
|
-
end
|
286
|
-
|
287
|
-
end
|
288
|
-
|
289
|
-
end
|
290
|
-
|
291
|
-
end
|
@@ -1,479 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Scenario, Integration' do
|
5
|
-
|
6
|
-
let(:clazz) { CukeModeler::Scenario }
|
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 = "#{SCENARIO_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 = 'Awww, look mate: Scenario 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('Scenario 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 'provides a descriptive filename when being parsed from stand alone text' do
|
41
|
-
source = "bad scenario text \n #{SCENARIO_KEYWORD}:\n And a step\n @foo "
|
42
|
-
|
43
|
-
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_scenario\.feature'/)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
|
47
|
-
scenario = clazz.new("@tag\n#{SCENARIO_KEYWORD}: test scenario\ndescription\n#{STEP_KEYWORD} a step")
|
48
|
-
data = scenario.parsing_data
|
49
|
-
|
50
|
-
expect(data.keys).to match_array([:background, :rule, :scenario])
|
51
|
-
expect(data[:scenario][:name]).to eq('test scenario')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
|
55
|
-
scenario = clazz.new("@tag\n#{SCENARIO_KEYWORD}: test scenario\ndescription\n#{STEP_KEYWORD} a step")
|
56
|
-
data = scenario.parsing_data
|
57
|
-
|
58
|
-
expect(data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps, :description])
|
59
|
-
expect(data[:type]).to eq(:Scenario)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
63
|
-
scenario = clazz.new("@tag\n#{SCENARIO_KEYWORD}: test scenario\ndescription\n#{STEP_KEYWORD} a step")
|
64
|
-
data = scenario.parsing_data
|
65
|
-
|
66
|
-
expect(data.keys).to match_array([:type, :tags, :location, :keyword, :name, :steps, :description])
|
67
|
-
expect(data[:type]).to eq(:Scenario)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
71
|
-
scenario = clazz.new("@tag\n#{SCENARIO_KEYWORD}: test scenario\ndescription\n#{STEP_KEYWORD} a step")
|
72
|
-
data = scenario.parsing_data
|
73
|
-
|
74
|
-
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'type', 'steps', 'tags'])
|
75
|
-
expect(data['keyword']).to eq('Scenario')
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'properly sets its child models' do
|
79
|
-
source = "@a_tag
|
80
|
-
#{SCENARIO_KEYWORD}: Test scenario
|
81
|
-
#{STEP_KEYWORD} a step"
|
82
|
-
|
83
|
-
scenario = clazz.new(source)
|
84
|
-
step = scenario.steps.first
|
85
|
-
tag = scenario.tags.first
|
86
|
-
|
87
|
-
expect(step.parent_model).to equal(scenario)
|
88
|
-
expect(tag.parent_model).to equal(scenario)
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'trims whitespace from its source description' do
|
92
|
-
source = ["#{SCENARIO_KEYWORD}:",
|
93
|
-
' ',
|
94
|
-
' description line 1',
|
95
|
-
'',
|
96
|
-
' description line 2',
|
97
|
-
' description line 3 ',
|
98
|
-
'',
|
99
|
-
'',
|
100
|
-
'',
|
101
|
-
" #{STEP_KEYWORD} a step"]
|
102
|
-
source = source.join("\n")
|
103
|
-
|
104
|
-
scenario = clazz.new(source)
|
105
|
-
description = scenario.description.split("\n", -1)
|
106
|
-
|
107
|
-
expect(description).to eq([' description line 1',
|
108
|
-
'',
|
109
|
-
'description line 2',
|
110
|
-
' description line 3'])
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
describe 'getting ancestors' do
|
115
|
-
|
116
|
-
before(:each) do
|
117
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'scenario_test_file', :directory => test_directory)
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
122
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
123
|
-
|
124
|
-
#{SCENARIO_KEYWORD}: Test test
|
125
|
-
#{STEP_KEYWORD} a step"
|
126
|
-
}
|
127
|
-
|
128
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
129
|
-
let(:scenario_model) { directory_model.feature_files.first.feature.tests.first }
|
130
|
-
|
131
|
-
|
132
|
-
it 'can get its directory' do
|
133
|
-
ancestor = scenario_model.get_ancestor(:directory)
|
134
|
-
|
135
|
-
expect(ancestor).to equal(directory_model)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'can get its feature file' do
|
139
|
-
ancestor = scenario_model.get_ancestor(:feature_file)
|
140
|
-
|
141
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'can get its feature' do
|
145
|
-
ancestor = scenario_model.get_ancestor(:feature)
|
146
|
-
|
147
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
151
|
-
ancestor = scenario_model.get_ancestor(:test)
|
152
|
-
|
153
|
-
expect(ancestor).to be_nil
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
|
-
|
159
|
-
describe 'model population' do
|
160
|
-
|
161
|
-
context 'from source text' do
|
162
|
-
|
163
|
-
let(:source_text) { "#{SCENARIO_KEYWORD}:" }
|
164
|
-
let(:scenario) { clazz.new(source_text) }
|
165
|
-
|
166
|
-
|
167
|
-
it "models the scenario's keyword" do
|
168
|
-
expect(scenario.keyword).to eq("#{SCENARIO_KEYWORD}")
|
169
|
-
end
|
170
|
-
|
171
|
-
it "models the scenario's source line" do
|
172
|
-
source_text = "#{FEATURE_KEYWORD}:
|
173
|
-
|
174
|
-
#{SCENARIO_KEYWORD}: foo
|
175
|
-
#{STEP_KEYWORD} step"
|
176
|
-
scenario = CukeModeler::Feature.new(source_text).tests.first
|
177
|
-
|
178
|
-
expect(scenario.source_line).to eq(3)
|
179
|
-
end
|
180
|
-
|
181
|
-
|
182
|
-
context 'a filled scenario' do
|
183
|
-
|
184
|
-
let(:source_text) { "@tag1 @tag2 @tag3
|
185
|
-
#{SCENARIO_KEYWORD}: Scenario name
|
186
|
-
|
187
|
-
Scenario description.
|
188
|
-
|
189
|
-
Some more.
|
190
|
-
Even more.
|
191
|
-
|
192
|
-
#{STEP_KEYWORD} a step
|
193
|
-
#{STEP_KEYWORD} another step" }
|
194
|
-
let(:scenario) { clazz.new(source_text) }
|
195
|
-
|
196
|
-
|
197
|
-
it "models the scenario's name" do
|
198
|
-
expect(scenario.name).to eq('Scenario name')
|
199
|
-
end
|
200
|
-
|
201
|
-
it "models the scenario's description" do
|
202
|
-
description = scenario.description.split("\n", -1)
|
203
|
-
|
204
|
-
expect(description).to eq([' Scenario description.',
|
205
|
-
'',
|
206
|
-
'Some more.',
|
207
|
-
' Even more.'])
|
208
|
-
end
|
209
|
-
|
210
|
-
it "models the scenario's steps" do
|
211
|
-
step_names = scenario.steps.collect { |step| step.text }
|
212
|
-
|
213
|
-
expect(step_names).to eq(['a step', 'another step'])
|
214
|
-
end
|
215
|
-
|
216
|
-
it "models the scenario's tags" do
|
217
|
-
tag_names = scenario.tags.collect { |tag| tag.name }
|
218
|
-
|
219
|
-
expect(tag_names).to eq(['@tag1', '@tag2', '@tag3'])
|
220
|
-
end
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
context 'an empty scenario' do
|
225
|
-
|
226
|
-
let(:source_text) { "#{SCENARIO_KEYWORD}:" }
|
227
|
-
let(:scenario) { clazz.new(source_text) }
|
228
|
-
|
229
|
-
|
230
|
-
it "models the scenario's name" do
|
231
|
-
expect(scenario.name).to eq('')
|
232
|
-
end
|
233
|
-
|
234
|
-
it "models the scenario's description" do
|
235
|
-
expect(scenario.description).to eq('')
|
236
|
-
end
|
237
|
-
|
238
|
-
it "models the scenario's steps" do
|
239
|
-
expect(scenario.steps).to eq([])
|
240
|
-
end
|
241
|
-
|
242
|
-
it "models the scenario's tags" do
|
243
|
-
expect(scenario.tags).to eq([])
|
244
|
-
end
|
245
|
-
|
246
|
-
end
|
247
|
-
|
248
|
-
end
|
249
|
-
|
250
|
-
end
|
251
|
-
|
252
|
-
|
253
|
-
describe 'comparison' do
|
254
|
-
|
255
|
-
it 'is equal to a background with the same steps' do
|
256
|
-
source = "#{SCENARIO_KEYWORD}:
|
257
|
-
#{STEP_KEYWORD} step 1
|
258
|
-
#{STEP_KEYWORD} step 2"
|
259
|
-
scenario = clazz.new(source)
|
260
|
-
|
261
|
-
source = "#{BACKGROUND_KEYWORD}:
|
262
|
-
#{STEP_KEYWORD} step 1
|
263
|
-
#{STEP_KEYWORD} step 2"
|
264
|
-
background_1 = CukeModeler::Background.new(source)
|
265
|
-
|
266
|
-
source = "#{BACKGROUND_KEYWORD}:
|
267
|
-
#{STEP_KEYWORD} step 2
|
268
|
-
#{STEP_KEYWORD} step 1"
|
269
|
-
background_2 = CukeModeler::Background.new(source)
|
270
|
-
|
271
|
-
|
272
|
-
expect(scenario).to eq(background_1)
|
273
|
-
expect(scenario).to_not eq(background_2)
|
274
|
-
end
|
275
|
-
|
276
|
-
it 'is equal to a scenario with the same steps' do
|
277
|
-
source = "#{SCENARIO_KEYWORD}:
|
278
|
-
#{STEP_KEYWORD} step 1
|
279
|
-
#{STEP_KEYWORD} step 2"
|
280
|
-
scenario_1 = clazz.new(source)
|
281
|
-
|
282
|
-
source = "#{SCENARIO_KEYWORD}:
|
283
|
-
#{STEP_KEYWORD} step 1
|
284
|
-
#{STEP_KEYWORD} step 2"
|
285
|
-
scenario_2 = clazz.new(source)
|
286
|
-
|
287
|
-
source = "#{SCENARIO_KEYWORD}:
|
288
|
-
#{STEP_KEYWORD} step 2
|
289
|
-
#{STEP_KEYWORD} step 1"
|
290
|
-
scenario_3 = clazz.new(source)
|
291
|
-
|
292
|
-
|
293
|
-
expect(scenario_1).to eq(scenario_2)
|
294
|
-
expect(scenario_1).to_not eq(scenario_3)
|
295
|
-
end
|
296
|
-
|
297
|
-
it 'is equal to an outline with the same steps' do
|
298
|
-
source = "#{SCENARIO_KEYWORD}:
|
299
|
-
#{STEP_KEYWORD} step 1
|
300
|
-
#{STEP_KEYWORD} step 2"
|
301
|
-
scenario = clazz.new(source)
|
302
|
-
|
303
|
-
source = "#{OUTLINE_KEYWORD}:
|
304
|
-
#{STEP_KEYWORD} step 1
|
305
|
-
#{STEP_KEYWORD} step 2
|
306
|
-
#{EXAMPLE_KEYWORD}:
|
307
|
-
| param |
|
308
|
-
| value |"
|
309
|
-
outline_1 = CukeModeler::Outline.new(source)
|
310
|
-
|
311
|
-
source = "#{OUTLINE_KEYWORD}:
|
312
|
-
#{STEP_KEYWORD} step 2
|
313
|
-
#{STEP_KEYWORD} step 1
|
314
|
-
#{EXAMPLE_KEYWORD}:
|
315
|
-
| param |
|
316
|
-
| value |"
|
317
|
-
outline_2 = CukeModeler::Outline.new(source)
|
318
|
-
|
319
|
-
|
320
|
-
expect(scenario).to eq(outline_1)
|
321
|
-
expect(scenario).to_not eq(outline_2)
|
322
|
-
end
|
323
|
-
|
324
|
-
end
|
325
|
-
|
326
|
-
|
327
|
-
describe 'scenario output' do
|
328
|
-
|
329
|
-
it 'can be remade from its own output' do
|
330
|
-
source = "@tag1 @tag2 @tag3
|
331
|
-
#{SCENARIO_KEYWORD}: A scenario with everything it could have
|
332
|
-
|
333
|
-
Including a description
|
334
|
-
and then some.
|
335
|
-
|
336
|
-
#{STEP_KEYWORD} a step
|
337
|
-
| value |
|
338
|
-
#{STEP_KEYWORD} another step
|
339
|
-
\"\"\"
|
340
|
-
some string
|
341
|
-
\"\"\""
|
342
|
-
scenario = clazz.new(source)
|
343
|
-
|
344
|
-
scenario_output = scenario.to_s
|
345
|
-
remade_scenario_output = clazz.new(scenario_output).to_s
|
346
|
-
|
347
|
-
expect(remade_scenario_output).to eq(scenario_output)
|
348
|
-
end
|
349
|
-
|
350
|
-
|
351
|
-
context 'from source text' do
|
352
|
-
|
353
|
-
it 'can output an empty scenario' do
|
354
|
-
source = ["#{SCENARIO_KEYWORD}:"]
|
355
|
-
source = source.join("\n")
|
356
|
-
scenario = clazz.new(source)
|
357
|
-
|
358
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
359
|
-
|
360
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}:"])
|
361
|
-
end
|
362
|
-
|
363
|
-
it 'can output a scenario that has a name' do
|
364
|
-
source = ["#{SCENARIO_KEYWORD}: test scenario"]
|
365
|
-
source = source.join("\n")
|
366
|
-
scenario = clazz.new(source)
|
367
|
-
|
368
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
369
|
-
|
370
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}: test scenario"])
|
371
|
-
end
|
372
|
-
|
373
|
-
it 'can output a scenario that has a description' do
|
374
|
-
source = ["#{SCENARIO_KEYWORD}:",
|
375
|
-
'Some description.',
|
376
|
-
'Some more description.']
|
377
|
-
source = source.join("\n")
|
378
|
-
scenario = clazz.new(source)
|
379
|
-
|
380
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
381
|
-
|
382
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}:",
|
383
|
-
'',
|
384
|
-
'Some description.',
|
385
|
-
'Some more description.'])
|
386
|
-
end
|
387
|
-
|
388
|
-
it 'can output a scenario that has steps' do
|
389
|
-
source = ["#{SCENARIO_KEYWORD}:",
|
390
|
-
"#{STEP_KEYWORD} a step",
|
391
|
-
'|value|',
|
392
|
-
"#{STEP_KEYWORD} another step",
|
393
|
-
'"""',
|
394
|
-
'some string',
|
395
|
-
'"""']
|
396
|
-
source = source.join("\n")
|
397
|
-
scenario = clazz.new(source)
|
398
|
-
|
399
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
400
|
-
|
401
|
-
expect(scenario_output).to eq(["#{SCENARIO_KEYWORD}:",
|
402
|
-
" #{STEP_KEYWORD} a step",
|
403
|
-
' | value |',
|
404
|
-
" #{STEP_KEYWORD} another step",
|
405
|
-
' """',
|
406
|
-
' some string',
|
407
|
-
' """'])
|
408
|
-
end
|
409
|
-
|
410
|
-
it 'can output a scenario that has tags' do
|
411
|
-
source = ['@tag1 @tag2',
|
412
|
-
'@tag3',
|
413
|
-
"#{SCENARIO_KEYWORD}:"]
|
414
|
-
source = source.join("\n")
|
415
|
-
scenario = clazz.new(source)
|
416
|
-
|
417
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
418
|
-
|
419
|
-
expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
|
420
|
-
"#{SCENARIO_KEYWORD}:"])
|
421
|
-
end
|
422
|
-
|
423
|
-
it 'can output a scenario that has everything' do
|
424
|
-
source = ['@tag1 @tag2 @tag3',
|
425
|
-
"#{SCENARIO_KEYWORD}: A scenario with everything it could have",
|
426
|
-
'Including a description',
|
427
|
-
'and then some.',
|
428
|
-
"#{STEP_KEYWORD} a step",
|
429
|
-
'|value|',
|
430
|
-
"#{STEP_KEYWORD} another step",
|
431
|
-
'"""',
|
432
|
-
'some string',
|
433
|
-
'"""']
|
434
|
-
source = source.join("\n")
|
435
|
-
scenario = clazz.new(source)
|
436
|
-
|
437
|
-
scenario_output = scenario.to_s.split("\n", -1)
|
438
|
-
|
439
|
-
expect(scenario_output).to eq(['@tag1 @tag2 @tag3',
|
440
|
-
"#{SCENARIO_KEYWORD}: A scenario with everything it could have",
|
441
|
-
'',
|
442
|
-
'Including a description',
|
443
|
-
'and then some.',
|
444
|
-
'',
|
445
|
-
" #{STEP_KEYWORD} a step",
|
446
|
-
' | value |',
|
447
|
-
" #{STEP_KEYWORD} another step",
|
448
|
-
' """',
|
449
|
-
' some string',
|
450
|
-
' """'])
|
451
|
-
end
|
452
|
-
|
453
|
-
end
|
454
|
-
|
455
|
-
|
456
|
-
context 'from abstract instantiation' do
|
457
|
-
|
458
|
-
let(:scenario) { clazz.new }
|
459
|
-
|
460
|
-
|
461
|
-
it 'can output a scenario that has only tags' do
|
462
|
-
scenario.tags = [CukeModeler::Tag.new]
|
463
|
-
|
464
|
-
expect { scenario.to_s }.to_not raise_error
|
465
|
-
end
|
466
|
-
|
467
|
-
it 'can output a scenario that has only steps' do
|
468
|
-
scenario.steps = [CukeModeler::Step.new]
|
469
|
-
|
470
|
-
expect { scenario.to_s }.to_not raise_error
|
471
|
-
end
|
472
|
-
|
473
|
-
end
|
474
|
-
|
475
|
-
end
|
476
|
-
|
477
|
-
end
|
478
|
-
|
479
|
-
end
|