cuke_modeler 0.4.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -17
- data/.travis.yml +1 -1
- data/Gemfile +4 -0
- data/History.rdoc +71 -3
- data/LICENSE.txt +22 -22
- data/README.md +24 -10
- data/Rakefile +2 -12
- data/cuke_modeler.gemspec +1 -1
- data/features/analysis/test_comparison.feature +37 -122
- data/features/modeling/background_modeling.feature +77 -0
- data/features/modeling/background_output.feature +42 -0
- data/features/modeling/cell_modeling.feature +23 -0
- data/features/modeling/cell_output.feature +22 -0
- data/features/modeling/directory_modeling.feature +65 -0
- data/features/modeling/directory_output.feature +12 -0
- data/features/modeling/doc_string_modeling.feature +61 -0
- data/features/modeling/doc_string_output.feature +32 -0
- data/features/modeling/example_modeling.feature +125 -0
- data/features/modeling/example_output.feature +39 -0
- data/features/modeling/feature_file_modeling.feature +40 -0
- data/features/modeling/feature_file_output.feature +12 -0
- data/features/modeling/feature_modeling.feature +109 -0
- data/features/modeling/feature_output.feature +104 -0
- data/features/modeling/model_output.feature +22 -0
- data/features/modeling/model_structure.feature +48 -0
- data/features/modeling/outline_modeling.feature +144 -0
- data/features/modeling/outline_output.feature +69 -0
- data/features/modeling/row_modeling.feature +48 -0
- data/features/modeling/row_output.feature +22 -0
- data/features/modeling/scenario_modeling.feature +118 -0
- data/features/modeling/scenario_output.feature +45 -0
- data/features/modeling/step_modeling.feature +84 -0
- data/features/modeling/step_output.feature +29 -0
- data/features/modeling/table_modeling.feature +50 -0
- data/features/modeling/table_output.feature +24 -0
- data/features/modeling/tag_modeling.feature +43 -0
- data/features/modeling/tag_output.feature +22 -0
- data/features/step_definitions/action_steps.rb +11 -1
- data/features/step_definitions/background_steps.rb +1 -85
- data/features/step_definitions/directory_steps.rb +2 -48
- data/features/step_definitions/doc_string_steps.rb +1 -67
- data/features/step_definitions/feature_file_steps.rb +2 -37
- data/features/step_definitions/feature_steps.rb +4 -100
- data/features/step_definitions/modeling_steps.rb +44 -0
- data/features/step_definitions/setup_steps.rb +19 -41
- data/features/step_definitions/step_steps.rb +2 -166
- data/features/step_definitions/table_steps.rb +1 -58
- data/features/step_definitions/tag_steps.rb +2 -72
- data/features/step_definitions/verification_steps.rb +152 -4
- data/features/support/env.rb +4 -6
- data/gemfiles/{gherkin.gemfile → gherkin2.gemfile} +4 -0
- data/gemfiles/gherkin3.gemfile +4 -0
- data/gemfiles/gherkin4.gemfile +4 -0
- data/lib/cuke_modeler.rb +24 -22
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +103 -31
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +103 -40
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +111 -50
- data/lib/cuke_modeler/containing.rb +255 -4
- data/lib/cuke_modeler/described.rb +28 -0
- data/lib/cuke_modeler/models/background.rb +66 -0
- data/lib/cuke_modeler/models/cell.rb +48 -0
- data/lib/cuke_modeler/models/directory.rb +95 -0
- data/lib/cuke_modeler/models/doc_string.rb +59 -0
- data/lib/cuke_modeler/models/example.rb +167 -0
- data/lib/cuke_modeler/models/feature.rb +106 -0
- data/lib/cuke_modeler/models/feature_file.rb +64 -0
- data/lib/cuke_modeler/models/model.rb +32 -0
- data/lib/cuke_modeler/models/outline.rb +79 -0
- data/lib/cuke_modeler/models/row.rb +49 -0
- data/lib/cuke_modeler/models/scenario.rb +69 -0
- data/lib/cuke_modeler/models/step.rb +68 -0
- data/lib/cuke_modeler/models/table.rb +67 -0
- data/lib/cuke_modeler/models/tag.rb +46 -0
- data/lib/cuke_modeler/named.rb +19 -0
- data/lib/cuke_modeler/nested.rb +22 -15
- data/lib/cuke_modeler/parsed.rb +11 -0
- data/lib/cuke_modeler/parsing.rb +66 -83
- data/lib/cuke_modeler/sourceable.rb +3 -11
- data/lib/cuke_modeler/stepped.rb +24 -0
- data/lib/cuke_modeler/taggable.rb +6 -29
- data/lib/cuke_modeler/version.rb +2 -1
- data/spec/integration/background_integration_spec.rb +332 -7
- data/spec/integration/cell_integration_spec.rb +321 -0
- data/spec/integration/directory_integration_spec.rb +175 -9
- data/spec/integration/doc_string_integration_spec.rb +318 -7
- data/spec/integration/example_integration_spec.rb +602 -19
- data/spec/integration/feature_file_integration_spec.rb +98 -3
- data/spec/integration/feature_integration_spec.rb +445 -27
- data/spec/integration/gherkin_2_adapter_spec.rb +122 -0
- data/spec/integration/gherkin_3_adapter_spec.rb +125 -0
- data/spec/integration/gherkin_4_adapter_spec.rb +123 -0
- data/spec/integration/model_integration_spec.rb +15 -0
- data/spec/integration/nested_integration_spec.rb +91 -0
- data/spec/integration/outline_integration_spec.rb +485 -12
- data/spec/integration/parsing_integration_spec.rb +85 -0
- data/spec/integration/row_integration_spec.rb +221 -18
- data/spec/integration/scenario_integration_spec.rb +368 -14
- data/spec/integration/shared/models_integration_specs.rb +18 -0
- data/spec/integration/step_integration_spec.rb +328 -77
- data/spec/integration/table_integration_spec.rb +242 -20
- data/spec/integration/tag_integration_spec.rb +178 -13
- data/spec/spec_helper.rb +32 -18
- data/spec/unit/background_unit_spec.rb +24 -44
- data/spec/unit/cell_unit_spec.rb +73 -0
- data/spec/unit/described_unit_spec.rb +23 -0
- data/spec/unit/directory_unit_spec.rb +52 -62
- data/spec/unit/doc_string_unit_spec.rb +47 -100
- data/spec/unit/example_unit_spec.rb +50 -296
- data/spec/unit/feature_file_unit_spec.rb +53 -52
- data/spec/unit/feature_unit_spec.rb +39 -83
- data/spec/unit/model_unit_spec.rb +15 -0
- data/spec/unit/named_unit_spec.rb +23 -0
- data/spec/unit/nested_unit_spec.rb +24 -21
- data/spec/unit/outline_unit_spec.rb +46 -69
- data/spec/unit/parsed_unit_spec.rb +27 -0
- data/spec/unit/parsing_unit_spec.rb +2 -70
- data/spec/unit/row_unit_spec.rb +22 -51
- data/spec/unit/scenario_unit_spec.rb +27 -59
- data/spec/unit/{bare_bones_unit_specs.rb → shared/bare_bones_models_unit_specs.rb} +2 -2
- data/spec/unit/shared/containing_models_unit_specs.rb +18 -0
- data/spec/unit/shared/described_models_unit_specs.rb +38 -0
- data/spec/unit/shared/models_unit_specs.rb +15 -0
- data/spec/unit/shared/named_models_unit_specs.rb +39 -0
- data/spec/unit/shared/nested_models_unit_specs.rb +51 -0
- data/spec/unit/shared/parsed_models_unit_specs.rb +39 -0
- data/spec/unit/shared/prepopulated_models_unit_specs.rb +18 -0
- data/spec/unit/shared/sourced_models_unit_specs.rb +39 -0
- data/spec/unit/shared/stepped_models_unit_specs.rb +46 -0
- data/spec/unit/shared/stringifiable_models_unit_specs.rb +18 -0
- data/spec/unit/shared/tagged_models_unit_specs.rb +72 -0
- data/spec/unit/sourceable_unit_spec.rb +12 -4
- data/spec/unit/step_unit_spec.rb +40 -231
- data/spec/unit/stepped_unit_spec.rb +23 -0
- data/spec/unit/table_unit_spec.rb +27 -89
- data/spec/unit/tag_unit_spec.rb +30 -53
- data/spec/unit/taggable_unit_spec.rb +26 -42
- data/todo.txt +32 -0
- metadata +135 -217
- data/features/analysis/test_manipulation.feature +0 -37
- data/features/modeling/gherkin/background_modeling.feature +0 -65
- data/features/modeling/gherkin/background_output.feature +0 -131
- data/features/modeling/gherkin/directory_modeling.feature +0 -110
- data/features/modeling/gherkin/directory_output.feature +0 -14
- data/features/modeling/gherkin/doc_string_modeling.feature +0 -53
- data/features/modeling/gherkin/doc_string_output.feature +0 -72
- data/features/modeling/gherkin/example_modeling.feature +0 -101
- data/features/modeling/gherkin/example_output.feature +0 -193
- data/features/modeling/gherkin/feature_file_modeling.feature +0 -54
- data/features/modeling/gherkin/feature_file_output.feature +0 -14
- data/features/modeling/gherkin/feature_modeling.feature +0 -154
- data/features/modeling/gherkin/feature_output.feature +0 -245
- data/features/modeling/gherkin/outline_modeling.feature +0 -90
- data/features/modeling/gherkin/outline_output.feature +0 -198
- data/features/modeling/gherkin/row_modeling.feature +0 -68
- data/features/modeling/gherkin/row_output.feature +0 -28
- data/features/modeling/gherkin/scenario_modeling.feature +0 -79
- data/features/modeling/gherkin/scenario_output.feature +0 -148
- data/features/modeling/gherkin/step_modeling.feature +0 -75
- data/features/modeling/gherkin/step_output.feature +0 -53
- data/features/modeling/gherkin/table_modeling.feature +0 -42
- data/features/modeling/gherkin/table_output.feature +0 -43
- data/features/modeling/gherkin/table_row_modeling.feature +0 -57
- data/features/modeling/gherkin/table_row_output.feature +0 -28
- data/features/modeling/gherkin/tag_modeling.feature +0 -48
- data/features/modeling/gherkin/tag_output.feature +0 -17
- data/features/modeling/gherkin3/background_modeling.feature +0 -64
- data/features/modeling/gherkin3/background_output.feature +0 -131
- data/features/modeling/gherkin3/directory_modeling.feature +0 -110
- data/features/modeling/gherkin3/directory_output.feature +0 -14
- data/features/modeling/gherkin3/doc_string_modeling.feature +0 -53
- data/features/modeling/gherkin3/doc_string_output.feature +0 -72
- data/features/modeling/gherkin3/example_modeling.feature +0 -100
- data/features/modeling/gherkin3/example_output.feature +0 -207
- data/features/modeling/gherkin3/feature_file_modeling.feature +0 -54
- data/features/modeling/gherkin3/feature_file_output.feature +0 -14
- data/features/modeling/gherkin3/feature_modeling.feature +0 -155
- data/features/modeling/gherkin3/feature_output.feature +0 -249
- data/features/modeling/gherkin3/outline_modeling.feature +0 -89
- data/features/modeling/gherkin3/outline_output.feature +0 -255
- data/features/modeling/gherkin3/row_modeling.feature +0 -68
- data/features/modeling/gherkin3/row_output.feature +0 -28
- data/features/modeling/gherkin3/scenario_modeling.feature +0 -78
- data/features/modeling/gherkin3/scenario_output.feature +0 -148
- data/features/modeling/gherkin3/step_modeling.feature +0 -75
- data/features/modeling/gherkin3/step_output.feature +0 -53
- data/features/modeling/gherkin3/table_modeling.feature +0 -42
- data/features/modeling/gherkin3/table_output.feature +0 -43
- data/features/modeling/gherkin3/table_row_modeling.feature +0 -57
- data/features/modeling/gherkin3/table_row_output.feature +0 -28
- data/features/modeling/gherkin3/tag_modeling.feature +0 -49
- data/features/modeling/gherkin3/tag_output.feature +0 -17
- data/features/modeling/gherkin4/background_modeling.feature +0 -64
- data/features/modeling/gherkin4/background_output.feature +0 -131
- data/features/modeling/gherkin4/directory_modeling.feature +0 -110
- data/features/modeling/gherkin4/directory_output.feature +0 -14
- data/features/modeling/gherkin4/doc_string_modeling.feature +0 -53
- data/features/modeling/gherkin4/doc_string_output.feature +0 -72
- data/features/modeling/gherkin4/example_modeling.feature +0 -100
- data/features/modeling/gherkin4/example_output.feature +0 -193
- data/features/modeling/gherkin4/feature_file_modeling.feature +0 -54
- data/features/modeling/gherkin4/feature_file_output.feature +0 -14
- data/features/modeling/gherkin4/feature_modeling.feature +0 -153
- data/features/modeling/gherkin4/feature_output.feature +0 -245
- data/features/modeling/gherkin4/outline_modeling.feature +0 -89
- data/features/modeling/gherkin4/outline_output.feature +0 -198
- data/features/modeling/gherkin4/row_modeling.feature +0 -68
- data/features/modeling/gherkin4/row_output.feature +0 -28
- data/features/modeling/gherkin4/scenario_modeling.feature +0 -78
- data/features/modeling/gherkin4/scenario_output.feature +0 -148
- data/features/modeling/gherkin4/step_modeling.feature +0 -75
- data/features/modeling/gherkin4/step_output.feature +0 -53
- data/features/modeling/gherkin4/table_modeling.feature +0 -42
- data/features/modeling/gherkin4/table_output.feature +0 -43
- data/features/modeling/gherkin4/table_row_modeling.feature +0 -57
- data/features/modeling/gherkin4/table_row_output.feature +0 -28
- data/features/modeling/gherkin4/tag_modeling.feature +0 -48
- data/features/modeling/gherkin4/tag_output.feature +0 -17
- data/features/step_definitions/outline_steps.rb +0 -258
- data/features/step_definitions/test_steps.rb +0 -123
- data/lib/cuke_modeler/background.rb +0 -38
- data/lib/cuke_modeler/directory.rb +0 -83
- data/lib/cuke_modeler/doc_string.rb +0 -87
- data/lib/cuke_modeler/example.rb +0 -195
- data/lib/cuke_modeler/feature.rb +0 -147
- data/lib/cuke_modeler/feature_element.rb +0 -73
- data/lib/cuke_modeler/feature_file.rb +0 -77
- data/lib/cuke_modeler/outline.rb +0 -68
- data/lib/cuke_modeler/raw.rb +0 -20
- data/lib/cuke_modeler/row.rb +0 -64
- data/lib/cuke_modeler/scenario.rb +0 -45
- data/lib/cuke_modeler/step.rb +0 -216
- data/lib/cuke_modeler/table.rb +0 -90
- data/lib/cuke_modeler/table_row.rb +0 -64
- data/lib/cuke_modeler/tag.rb +0 -62
- data/lib/cuke_modeler/test_element.rb +0 -79
- data/lib/cuke_modeler/world.rb +0 -113
- data/spec/integration/table_row_integration_spec.rb +0 -76
- data/spec/integration/world_integration_spec.rb +0 -14
- data/spec/unit/containing_element_unit_specs.rb +0 -18
- data/spec/unit/feature_element_unit_spec.rb +0 -19
- data/spec/unit/feature_element_unit_specs.rb +0 -52
- data/spec/unit/nested_element_unit_specs.rb +0 -39
- data/spec/unit/prepopulated_unit_specs.rb +0 -14
- data/spec/unit/raw_element_unit_specs.rb +0 -27
- data/spec/unit/raw_unit_spec.rb +0 -28
- data/spec/unit/sourced_element_unit_specs.rb +0 -18
- data/spec/unit/table_row_unit_spec.rb +0 -102
- data/spec/unit/tagged_element_unit_specs.rb +0 -67
- data/spec/unit/test_element_unit_spec.rb +0 -54
- data/spec/unit/test_element_unit_specs.rb +0 -34
- data/spec/unit/world_unit_spec.rb +0 -140
@@ -1,21 +1,78 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
SimpleCov.command_name('FeatureFile') unless RUBY_VERSION.to_s < '1.9.0'
|
4
3
|
|
5
4
|
describe 'FeatureFile, Integration' do
|
6
5
|
|
7
6
|
let(:clazz) { CukeModeler::FeatureFile }
|
8
7
|
|
9
8
|
|
9
|
+
describe 'common behavior' do
|
10
|
+
|
11
|
+
it_should_behave_like 'a model, integration'
|
12
|
+
|
13
|
+
end
|
14
|
+
|
10
15
|
describe 'unique behavior' do
|
11
16
|
|
17
|
+
it 'provides its own filename when being parsed' do
|
18
|
+
path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
19
|
+
File.open(path, "w") { |file| file.puts 'bad feature text' }
|
20
|
+
|
21
|
+
expect { clazz.new(path) }.to raise_error(/'#{path}'/)
|
22
|
+
end
|
23
|
+
|
12
24
|
it 'cannot model a non-existent feature file' do
|
13
25
|
path = "#{@default_file_directory}/missing_file.txt"
|
14
26
|
|
15
27
|
expect { clazz.new(path) }.to raise_error(ArgumentError)
|
16
28
|
end
|
17
29
|
|
18
|
-
|
30
|
+
|
31
|
+
describe 'model population' do
|
32
|
+
|
33
|
+
let(:source_text) { "Feature: Test feature" }
|
34
|
+
let(:feature_file_path) { "#{@default_file_directory}/#{@default_feature_file_name}" }
|
35
|
+
let(:feature_file) { clazz.new(feature_file_path) }
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
File.open(feature_file_path, "w") { |file| file.puts source_text }
|
39
|
+
end
|
40
|
+
|
41
|
+
it "models the feature file's name" do
|
42
|
+
expect(feature_file.name).to eq(@default_feature_file_name)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "models the feature file's path" do
|
46
|
+
expect(feature_file.path).to eq(feature_file_path)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "models the feature file's feature" do
|
50
|
+
feature_name = feature_file.feature.name
|
51
|
+
|
52
|
+
expect(feature_name).to eq('Test feature')
|
53
|
+
end
|
54
|
+
|
55
|
+
# gherkin 3.x does not accept empty feature files
|
56
|
+
context 'an empty feature file', :gherkin3 => false do
|
57
|
+
|
58
|
+
let(:source_text) { '' }
|
59
|
+
let(:feature_file_path) { "#{@default_file_directory}/#{@default_feature_file_name}" }
|
60
|
+
let(:feature_file) { clazz.new(feature_file_path) }
|
61
|
+
|
62
|
+
before(:each) do
|
63
|
+
File.open(feature_file_path, "w") { |file| file.puts source_text }
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
it "models the feature file's feature" do
|
68
|
+
expect(feature_file.feature).to be_nil
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'properly sets its child models' do
|
19
76
|
file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
20
77
|
|
21
78
|
File.open(file_path, "w") { |file|
|
@@ -25,9 +82,10 @@ describe 'FeatureFile, Integration' do
|
|
25
82
|
file = clazz.new(file_path)
|
26
83
|
feature = file.feature
|
27
84
|
|
28
|
-
expect(feature.
|
85
|
+
expect(feature.parent_model).to equal(file)
|
29
86
|
end
|
30
87
|
|
88
|
+
|
31
89
|
describe 'getting ancestors' do
|
32
90
|
|
33
91
|
before(:each) do
|
@@ -53,6 +111,43 @@ describe 'FeatureFile, Integration' do
|
|
53
111
|
|
54
112
|
end
|
55
113
|
|
114
|
+
|
115
|
+
describe 'feature file output' do
|
116
|
+
|
117
|
+
context 'from source text' do
|
118
|
+
|
119
|
+
let(:source_text) { "Feature: Test feature" }
|
120
|
+
let(:feature_file_path) { "#{@default_file_directory}/#{@default_feature_file_name}" }
|
121
|
+
let(:feature_file) { clazz.new(feature_file_path) }
|
122
|
+
|
123
|
+
before(:each) do
|
124
|
+
File.open(feature_file_path, "w") { |file| file.puts source_text }
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
it 'can output a feature file' do
|
129
|
+
feature_file_output = feature_file.to_s
|
130
|
+
|
131
|
+
expect(feature_file_output).to eq(feature_file_path)
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'can be remade from its own output' do
|
137
|
+
path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
138
|
+
File.open(path, "w") { |file| file.puts "Feature:" }
|
139
|
+
|
140
|
+
source = path
|
141
|
+
feature_file = clazz.new(source)
|
142
|
+
|
143
|
+
feature_file_output = feature_file.to_s
|
144
|
+
remade_feature_file_output = clazz.new(feature_file_output).to_s
|
145
|
+
|
146
|
+
expect(remade_feature_file_output).to eq(feature_file_output)
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
56
151
|
end
|
57
152
|
|
58
153
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
SimpleCov.command_name('Feature') unless RUBY_VERSION.to_s < '1.9.0'
|
4
3
|
|
5
4
|
describe 'Feature, Integration' do
|
6
5
|
|
@@ -8,9 +7,27 @@ describe 'Feature, Integration' do
|
|
8
7
|
let(:feature) { clazz.new }
|
9
8
|
|
10
9
|
|
10
|
+
describe 'common behavior' do
|
11
|
+
|
12
|
+
it_should_behave_like 'a model, integration'
|
13
|
+
|
14
|
+
end
|
15
|
+
|
11
16
|
describe 'unique behavior' do
|
12
17
|
|
13
|
-
it '
|
18
|
+
it 'can be instantiated with the minimum viable Gherkin' do
|
19
|
+
source = 'Feature:'
|
20
|
+
|
21
|
+
expect { clazz.new(source) }.to_not raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'provides a descriptive filename when being parsed from stand alone text' do
|
25
|
+
source = 'bad feature text'
|
26
|
+
|
27
|
+
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_feature\.feature'/)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'properly sets its child models' do
|
14
31
|
source = ['@a_tag',
|
15
32
|
'Feature: Test feature',
|
16
33
|
' Background: Test background',
|
@@ -26,13 +43,59 @@ describe 'Feature, Integration' do
|
|
26
43
|
background = feature.background
|
27
44
|
scenario = feature.tests[0]
|
28
45
|
outline = feature.tests[1]
|
29
|
-
tag = feature.
|
46
|
+
tag = feature.tags[0]
|
30
47
|
|
31
48
|
|
32
|
-
expect(outline.
|
33
|
-
expect(scenario.
|
34
|
-
expect(background.
|
35
|
-
expect(tag.
|
49
|
+
expect(outline.parent_model).to equal(feature)
|
50
|
+
expect(scenario.parent_model).to equal(feature)
|
51
|
+
expect(background.parent_model).to equal(feature)
|
52
|
+
expect(tag.parent_model).to equal(feature)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
|
56
|
+
feature = clazz.new("@tag\nFeature: test feature\ndescription\nBackground:\nScenario:")
|
57
|
+
data = feature.parsing_data
|
58
|
+
|
59
|
+
expect(data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :children, :description])
|
60
|
+
expect(data[:type]).to eq(:Feature)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
64
|
+
feature = clazz.new("@tag\nFeature: test feature\ndescription\nBackground:\nScenario:")
|
65
|
+
data = feature.parsing_data
|
66
|
+
|
67
|
+
expect(data.keys).to match_array([:type, :tags, :location, :language, :keyword, :name, :scenarioDefinitions, :comments, :background, :description])
|
68
|
+
expect(data[:type]).to eq(:Feature)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
72
|
+
feature = clazz.new("@tag\nFeature: test feature\ndescription\nBackground:\nScenario:")
|
73
|
+
data = feature.parsing_data
|
74
|
+
|
75
|
+
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'uri', 'elements', 'tags'])
|
76
|
+
expect(data['keyword']).to eq('Feature')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'trims whitespace from its source description' do
|
80
|
+
source = ['Feature:',
|
81
|
+
' ',
|
82
|
+
' description line 1',
|
83
|
+
'',
|
84
|
+
' description line 2',
|
85
|
+
' description line 3 ',
|
86
|
+
'',
|
87
|
+
'',
|
88
|
+
'',
|
89
|
+
' Scenario:']
|
90
|
+
source = source.join("\n")
|
91
|
+
|
92
|
+
feature = clazz.new(source)
|
93
|
+
description = feature.description.split("\n")
|
94
|
+
|
95
|
+
expect(description).to eq([' description line 1',
|
96
|
+
'',
|
97
|
+
'description line 2',
|
98
|
+
' description line 3'])
|
36
99
|
end
|
37
100
|
|
38
101
|
it 'can selectively access its scenarios and outlines' do
|
@@ -45,28 +108,127 @@ describe 'Feature, Integration' do
|
|
45
108
|
expect(feature.outlines).to match_array(outlines)
|
46
109
|
end
|
47
110
|
|
48
|
-
it 'knows how many scenarios it has' do
|
49
|
-
scenarios = [CukeModeler::Scenario.new, CukeModeler::Scenario.new]
|
50
|
-
outlines = [CukeModeler::Outline.new]
|
51
111
|
|
52
|
-
|
53
|
-
expect(feature.scenario_count).to eq(0)
|
112
|
+
describe 'model population' do
|
54
113
|
|
55
|
-
|
56
|
-
expect(feature.scenario_count).to eq(2)
|
57
|
-
end
|
114
|
+
context 'from source text' do
|
58
115
|
|
59
|
-
|
60
|
-
|
61
|
-
|
116
|
+
it "models the feature's source line" do
|
117
|
+
source_text = "Feature:"
|
118
|
+
feature = CukeModeler::Feature.new(source_text)
|
62
119
|
|
63
|
-
|
64
|
-
|
120
|
+
expect(feature.source_line).to eq(1)
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
context 'a filled feature' do
|
125
|
+
|
126
|
+
let(:source_text) { '@tag_1 @tag_2
|
127
|
+
Feature: Feature Foo
|
128
|
+
|
129
|
+
Some feature description.
|
130
|
+
|
131
|
+
Some more.
|
132
|
+
And some more.
|
133
|
+
|
134
|
+
Background: The background
|
135
|
+
* some setup step
|
136
|
+
|
137
|
+
Scenario: Scenario 1
|
138
|
+
* a step
|
139
|
+
|
140
|
+
Scenario Outline: Outline 1
|
141
|
+
* a step
|
142
|
+
Examples:
|
143
|
+
| param |
|
144
|
+
| value |
|
145
|
+
|
146
|
+
Scenario: Scenario 2
|
147
|
+
* a step
|
148
|
+
|
149
|
+
Scenario Outline: Outline 2
|
150
|
+
* a step
|
151
|
+
Examples:
|
152
|
+
| param |
|
153
|
+
| value |' }
|
154
|
+
let(:feature) { clazz.new(source_text) }
|
155
|
+
|
156
|
+
|
157
|
+
it "models the feature's name" do
|
158
|
+
expect(feature.name).to eq('Feature Foo')
|
159
|
+
end
|
160
|
+
|
161
|
+
it "models the feature's description" do
|
162
|
+
description = feature.description.split("\n")
|
163
|
+
|
164
|
+
expect(description).to eq([' Some feature description.',
|
165
|
+
'',
|
166
|
+
'Some more.',
|
167
|
+
' And some more.'])
|
168
|
+
end
|
169
|
+
|
170
|
+
it "models the feature's background" do
|
171
|
+
expect(feature.background.name).to eq('The background')
|
172
|
+
end
|
173
|
+
|
174
|
+
it "models the feature's scenarios" do
|
175
|
+
scenario_names = feature.scenarios.collect { |scenario| scenario.name }
|
176
|
+
|
177
|
+
expect(scenario_names).to eq(['Scenario 1', 'Scenario 2'])
|
178
|
+
end
|
179
|
+
|
180
|
+
it "models the feature's outlines" do
|
181
|
+
outline_names = feature.outlines.collect { |outline| outline.name }
|
182
|
+
|
183
|
+
expect(outline_names).to eq(['Outline 1', 'Outline 2'])
|
184
|
+
end
|
185
|
+
|
186
|
+
it "models the feature's tags" do
|
187
|
+
tag_names = feature.tags.collect { |tag| tag.name }
|
188
|
+
|
189
|
+
expect(tag_names).to eq(['@tag_1', '@tag_2'])
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
context 'an empty feature' do
|
196
|
+
|
197
|
+
let(:source_text) { 'Feature:' }
|
198
|
+
let(:feature) { clazz.new(source_text) }
|
199
|
+
|
200
|
+
|
201
|
+
it "models the feature's name" do
|
202
|
+
expect(feature.name).to eq('')
|
203
|
+
end
|
204
|
+
|
205
|
+
it "models the feature's description" do
|
206
|
+
expect(feature.description).to eq('')
|
207
|
+
end
|
208
|
+
|
209
|
+
it "models the feature's background" do
|
210
|
+
expect(feature.background).to be_nil
|
211
|
+
end
|
212
|
+
|
213
|
+
it "models the feature's scenarios" do
|
214
|
+
expect(feature.scenarios).to eq([])
|
215
|
+
end
|
216
|
+
|
217
|
+
it "models the feature's outlines" do
|
218
|
+
expect(feature.outlines).to eq([])
|
219
|
+
end
|
220
|
+
|
221
|
+
it "models the feature's tags" do
|
222
|
+
expect(feature.tags).to eq([])
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
65
228
|
|
66
|
-
feature.tests = scenarios + outlines
|
67
|
-
expect(feature.outline_count).to eq(2)
|
68
229
|
end
|
69
230
|
|
231
|
+
|
70
232
|
it 'knows how many test cases it has' do
|
71
233
|
source_1 = ['Feature: Test feature']
|
72
234
|
source_1 = source_1.join("\n")
|
@@ -101,7 +263,7 @@ describe 'Feature, Integration' do
|
|
101
263
|
end
|
102
264
|
|
103
265
|
let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
|
104
|
-
let(:feature) { directory.feature_files.first.
|
266
|
+
let(:feature) { directory.feature_files.first.feature }
|
105
267
|
|
106
268
|
|
107
269
|
it 'can get its directory' do
|
@@ -124,15 +286,271 @@ describe 'Feature, Integration' do
|
|
124
286
|
|
125
287
|
end
|
126
288
|
|
127
|
-
describe 'feature output edge cases' do
|
128
289
|
|
129
|
-
|
290
|
+
describe 'feature output' do
|
291
|
+
|
292
|
+
it 'can be remade from its own output' do
|
293
|
+
source = ['@tag1 @tag2 @tag3',
|
294
|
+
'Feature: A feature with everything it could have',
|
295
|
+
'',
|
296
|
+
'Including a description',
|
297
|
+
'and then some.',
|
298
|
+
'',
|
299
|
+
' Background:',
|
300
|
+
'',
|
301
|
+
' Background',
|
302
|
+
' description',
|
303
|
+
'',
|
304
|
+
' * a step',
|
305
|
+
' | value1 |',
|
306
|
+
' * another step ',
|
307
|
+
'',
|
308
|
+
' @scenario_tag ',
|
309
|
+
' Scenario:',
|
310
|
+
'',
|
311
|
+
' Scenario ',
|
312
|
+
' description ',
|
313
|
+
'',
|
314
|
+
' * a step ',
|
315
|
+
' * another step ',
|
316
|
+
' """"',
|
317
|
+
' some text ',
|
318
|
+
' """',
|
319
|
+
'',
|
320
|
+
' @outline_tag ',
|
321
|
+
' Scenario Outline: ',
|
322
|
+
'',
|
323
|
+
' Outline ',
|
324
|
+
' description ',
|
325
|
+
'',
|
326
|
+
' * a step ',
|
327
|
+
' | value2 |',
|
328
|
+
' * another step ',
|
329
|
+
' """',
|
330
|
+
' some text ',
|
331
|
+
' """',
|
332
|
+
'',
|
333
|
+
' @example_tag ',
|
334
|
+
' Examples:',
|
335
|
+
'',
|
336
|
+
' Example ',
|
337
|
+
' description',
|
338
|
+
'',
|
339
|
+
' | param |',
|
340
|
+
' | value |']
|
341
|
+
source = source.join(" \n")
|
342
|
+
feature = clazz.new(source)
|
343
|
+
|
344
|
+
feature_output = feature.to_s
|
345
|
+
remade_feature_output = clazz.new(feature_output).to_s
|
346
|
+
|
347
|
+
expect(remade_feature_output).to eq(feature_output)
|
348
|
+
end
|
349
|
+
|
350
|
+
|
351
|
+
context 'from source text' do
|
352
|
+
|
353
|
+
it 'can output an empty feature' do
|
354
|
+
source = ['Feature:']
|
355
|
+
source = source.join("\n")
|
356
|
+
feature = clazz.new(source)
|
357
|
+
|
358
|
+
feature_output = feature.to_s.split("\n")
|
359
|
+
|
360
|
+
expect(feature_output).to eq(['Feature:'])
|
361
|
+
end
|
362
|
+
|
363
|
+
it 'can output a feature that has a name' do
|
364
|
+
source = ['Feature: test feature']
|
365
|
+
source = source.join("\n")
|
366
|
+
feature = clazz.new(source)
|
367
|
+
|
368
|
+
feature_output = feature.to_s.split("\n")
|
369
|
+
|
370
|
+
expect(feature_output).to eq(['Feature: test feature'])
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'can output a feature that has a description' do
|
374
|
+
source = ['Feature:',
|
375
|
+
'Some description.',
|
376
|
+
'Some more description.']
|
377
|
+
source = source.join("\n")
|
378
|
+
feature = clazz.new(source)
|
379
|
+
|
380
|
+
feature_output = feature.to_s.split("\n")
|
381
|
+
|
382
|
+
expect(feature_output).to eq(['Feature:',
|
383
|
+
'',
|
384
|
+
'Some description.',
|
385
|
+
'Some more description.'])
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'can output a feature that has tags' do
|
389
|
+
source = ['@tag1 @tag2',
|
390
|
+
'@tag3',
|
391
|
+
'Feature:']
|
392
|
+
source = source.join("\n")
|
393
|
+
feature = clazz.new(source)
|
394
|
+
|
395
|
+
feature_output = feature.to_s.split("\n")
|
396
|
+
|
397
|
+
expect(feature_output).to eq(['@tag1 @tag2 @tag3',
|
398
|
+
'Feature:'])
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'can output a feature that has a background' do
|
402
|
+
source = ['Feature:',
|
403
|
+
'Background:',
|
404
|
+
'* a step']
|
405
|
+
source = source.join("\n")
|
406
|
+
feature = clazz.new(source)
|
407
|
+
|
408
|
+
feature_output = feature.to_s.split("\n")
|
409
|
+
|
410
|
+
expect(feature_output).to eq(['Feature:',
|
411
|
+
'',
|
412
|
+
' Background:',
|
413
|
+
' * a step'])
|
414
|
+
end
|
415
|
+
|
416
|
+
it 'can output a feature that has a scenario' do
|
417
|
+
source = ['Feature:',
|
418
|
+
'Scenario:',
|
419
|
+
'* a step']
|
420
|
+
source = source.join("\n")
|
421
|
+
feature = clazz.new(source)
|
422
|
+
|
423
|
+
feature_output = feature.to_s.split("\n")
|
424
|
+
|
425
|
+
expect(feature_output).to eq(['Feature:',
|
426
|
+
'',
|
427
|
+
' Scenario:',
|
428
|
+
' * a step'])
|
429
|
+
end
|
430
|
+
|
431
|
+
it 'can output a feature that has an outline' do
|
432
|
+
source = ['Feature:',
|
433
|
+
'Scenario Outline:',
|
434
|
+
'* a step',
|
435
|
+
'Examples:',
|
436
|
+
'|param|',
|
437
|
+
'|value|']
|
438
|
+
source = source.join("\n")
|
439
|
+
feature = clazz.new(source)
|
440
|
+
|
441
|
+
feature_output = feature.to_s.split("\n")
|
442
|
+
|
443
|
+
expect(feature_output).to eq(['Feature:',
|
444
|
+
'',
|
445
|
+
' Scenario Outline:',
|
446
|
+
' * a step',
|
447
|
+
'',
|
448
|
+
' Examples:',
|
449
|
+
' | param |',
|
450
|
+
' | value |'])
|
451
|
+
end
|
452
|
+
|
453
|
+
it 'can output a feature that has everything' do
|
454
|
+
source = ['@tag1 @tag2 @tag3',
|
455
|
+
'Feature: A feature with everything it could have',
|
456
|
+
'Including a description',
|
457
|
+
'and then some.',
|
458
|
+
'Background:',
|
459
|
+
'Background',
|
460
|
+
'description',
|
461
|
+
'* a step',
|
462
|
+
'|value1|',
|
463
|
+
'* another step',
|
464
|
+
'@scenario_tag',
|
465
|
+
'Scenario:',
|
466
|
+
'Scenario',
|
467
|
+
'description',
|
468
|
+
'* a step',
|
469
|
+
'* another step',
|
470
|
+
'"""',
|
471
|
+
'some text',
|
472
|
+
'"""',
|
473
|
+
'@outline_tag',
|
474
|
+
'Scenario Outline:',
|
475
|
+
'Outline ',
|
476
|
+
'description',
|
477
|
+
'* a step ',
|
478
|
+
'|value2|',
|
479
|
+
'* another step',
|
480
|
+
'"""',
|
481
|
+
'some text',
|
482
|
+
'"""',
|
483
|
+
'@example_tag',
|
484
|
+
'Examples:',
|
485
|
+
'Example',
|
486
|
+
'description',
|
487
|
+
'|param|',
|
488
|
+
'|value|']
|
489
|
+
source = source.join("\n")
|
490
|
+
feature = clazz.new(source)
|
491
|
+
|
492
|
+
feature_output = feature.to_s.split("\n")
|
493
|
+
|
494
|
+
expect(feature_output).to eq(['@tag1 @tag2 @tag3',
|
495
|
+
'Feature: A feature with everything it could have',
|
496
|
+
'',
|
497
|
+
'Including a description',
|
498
|
+
'and then some.',
|
499
|
+
'',
|
500
|
+
' Background:',
|
501
|
+
'',
|
502
|
+
' Background',
|
503
|
+
' description',
|
504
|
+
'',
|
505
|
+
' * a step',
|
506
|
+
' | value1 |',
|
507
|
+
' * another step',
|
508
|
+
'',
|
509
|
+
' @scenario_tag',
|
510
|
+
' Scenario:',
|
511
|
+
'',
|
512
|
+
' Scenario',
|
513
|
+
' description',
|
514
|
+
'',
|
515
|
+
' * a step',
|
516
|
+
' * another step',
|
517
|
+
' """',
|
518
|
+
' some text',
|
519
|
+
' """',
|
520
|
+
'',
|
521
|
+
' @outline_tag',
|
522
|
+
' Scenario Outline:',
|
523
|
+
'',
|
524
|
+
' Outline',
|
525
|
+
' description',
|
526
|
+
'',
|
527
|
+
' * a step',
|
528
|
+
' | value2 |',
|
529
|
+
' * another step',
|
530
|
+
' """',
|
531
|
+
' some text',
|
532
|
+
' """',
|
533
|
+
'',
|
534
|
+
' @example_tag',
|
535
|
+
' Examples:',
|
536
|
+
'',
|
537
|
+
' Example',
|
538
|
+
' description',
|
539
|
+
'',
|
540
|
+
' | param |',
|
541
|
+
' | value |'])
|
542
|
+
end
|
543
|
+
|
544
|
+
end
|
545
|
+
|
546
|
+
|
547
|
+
context 'from abstract instantiation' do
|
130
548
|
|
131
549
|
let(:feature) { clazz.new }
|
132
550
|
|
133
551
|
|
134
|
-
it 'can output a feature that has only
|
135
|
-
feature.
|
552
|
+
it 'can output a feature that has only tags' do
|
553
|
+
feature.tags = [CukeModeler::Tag.new]
|
136
554
|
|
137
555
|
expect { feature.to_s }.to_not raise_error
|
138
556
|
end
|