cuke_modeler 1.2.1 → 1.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/.simplecov +1 -2
- data/.travis.yml +4 -3
- data/Gemfile +1 -1
- data/History.md +5 -0
- data/README.md +2 -1
- data/Rakefile +19 -0
- data/appveyor.yml +19 -18
- data/cuke_modeler.gemspec +1 -1
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +1 -1
- data/lib/cuke_modeler/parsing.rb +1 -1
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/analysis/test_comparison.feature +1 -4
- data/testing/cucumber/features/modeling/background_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/background_output.feature +1 -2
- data/testing/cucumber/features/modeling/cell_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/comment_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/comment_output.feature +1 -2
- data/testing/cucumber/features/modeling/directory_modeling.feature +1 -4
- data/testing/cucumber/features/modeling/directory_output.feature +1 -2
- data/testing/cucumber/features/modeling/doc_string_modeling.feature +1 -3
- data/testing/cucumber/features/modeling/doc_string_output.feature +1 -2
- data/testing/cucumber/features/modeling/example_modeling.feature +1 -3
- data/testing/cucumber/features/modeling/example_output.feature +1 -2
- data/testing/cucumber/features/modeling/feature_file_modeling.feature +1 -3
- data/testing/cucumber/features/modeling/feature_file_output.feature +1 -2
- data/testing/cucumber/features/modeling/feature_modeling.feature +2 -5
- data/testing/cucumber/features/modeling/feature_output.feature +1 -2
- data/testing/cucumber/features/modeling/model_output.feature +1 -3
- data/testing/cucumber/features/modeling/model_structure.feature +3 -9
- data/testing/cucumber/features/modeling/outline_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/outline_output.feature +1 -2
- data/testing/cucumber/features/modeling/row_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/row_output.feature +1 -2
- data/testing/cucumber/features/modeling/scenario_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/scenario_output.feature +1 -2
- data/testing/cucumber/features/modeling/step_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/step_output.feature +1 -2
- data/testing/cucumber/features/modeling/table_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/table_output.feature +1 -2
- data/testing/cucumber/features/modeling/tag_modeling.feature +1 -2
- data/testing/cucumber/features/modeling/tag_output.feature +1 -2
- data/testing/cucumber/step_definitions/directory_steps.rb +1 -1
- data/testing/cucumber/step_definitions/feature_file_steps.rb +1 -1
- data/testing/cucumber/step_definitions/modeling_steps.rb +1 -1
- data/testing/cucumber/step_definitions/setup_steps.rb +4 -6
- data/testing/cucumber/step_definitions/verification_steps.rb +3 -3
- data/testing/cucumber/support/env.rb +7 -14
- data/testing/file_helper.rb +44 -0
- data/testing/gemfiles/gherkin5.gemfile +20 -0
- data/testing/rspec/spec/integration/background_integration_spec.rb +17 -15
- data/testing/rspec/spec/integration/cell_integration_spec.rb +69 -79
- data/testing/rspec/spec/integration/comment_integration_spec.rb +16 -15
- data/testing/rspec/spec/integration/directory_integration_spec.rb +46 -55
- data/testing/rspec/spec/integration/doc_string_integration_spec.rb +73 -80
- data/testing/rspec/spec/integration/example_integration_spec.rb +53 -36
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +27 -42
- data/testing/rspec/spec/integration/feature_integration_spec.rb +12 -11
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +14 -16
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +14 -16
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +14 -16
- data/testing/rspec/spec/integration/outline_integration_spec.rb +20 -18
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +1 -1
- data/testing/rspec/spec/integration/row_integration_spec.rb +57 -64
- data/testing/rspec/spec/integration/scenario_integration_spec.rb +17 -15
- data/testing/rspec/spec/integration/step_integration_spec.rb +48 -55
- data/testing/rspec/spec/integration/table_integration_spec.rb +54 -61
- data/testing/rspec/spec/integration/tag_integration_spec.rb +61 -67
- data/testing/rspec/spec/spec_helper.rb +5 -16
- data/testing/rspec/spec/unit/background_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -6
- data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/example_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/outline_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/row_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +1 -1
- data/testing/rspec/spec/unit/step_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/table_unit_spec.rb +0 -5
- data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -5
- data/todo.txt +0 -4
- metadata +6 -4
@@ -71,31 +71,33 @@ describe 'Comment, Integration' do
|
|
71
71
|
describe 'getting ancestors' do
|
72
72
|
|
73
73
|
before(:each) do
|
74
|
-
|
75
|
-
#{@feature_keyword}: Test feature"
|
76
|
-
|
77
|
-
file_path = "#{@default_file_directory}/comment_test_file.feature"
|
78
|
-
File.open(file_path, 'w') { |file| file.write(source) }
|
74
|
+
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'comment_test_file', :directory => test_directory)
|
79
75
|
end
|
80
76
|
|
81
|
-
|
82
|
-
let(:
|
77
|
+
|
78
|
+
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
79
|
+
let(:source_gherkin) { "# feature comment
|
80
|
+
#{@feature_keyword}: Test feature"
|
81
|
+
}
|
82
|
+
|
83
|
+
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
84
|
+
let(:comment_model) { directory_model.feature_files.first.comments.first }
|
83
85
|
|
84
86
|
|
85
87
|
it 'can get its directory' do
|
86
|
-
ancestor =
|
88
|
+
ancestor = comment_model.get_ancestor(:directory)
|
87
89
|
|
88
|
-
expect(ancestor).to equal(
|
90
|
+
expect(ancestor).to equal(directory_model)
|
89
91
|
end
|
90
92
|
|
91
93
|
it 'can get its feature file' do
|
92
|
-
ancestor =
|
94
|
+
ancestor = comment_model.get_ancestor(:feature_file)
|
93
95
|
|
94
|
-
expect(ancestor).to equal(
|
96
|
+
expect(ancestor).to equal(directory_model.feature_files.first)
|
95
97
|
end
|
96
98
|
|
97
99
|
it 'returns nil if it does not have the requested type of ancestor' do
|
98
|
-
ancestor =
|
100
|
+
ancestor = comment_model.get_ancestor(:example)
|
99
101
|
|
100
102
|
expect(ancestor).to be_nil
|
101
103
|
end
|
@@ -116,12 +118,11 @@ describe 'Comment, Integration' do
|
|
116
118
|
end
|
117
119
|
|
118
120
|
it "models the comment's source line" do
|
119
|
-
path = "#{@default_file_directory}/#{@default_feature_file_name}"
|
120
121
|
source_text = "# a comment
|
121
122
|
#{@feature_keyword}:"
|
122
123
|
|
123
|
-
|
124
|
-
comment = CukeModeler::FeatureFile.new(
|
124
|
+
test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'comment_test_file')
|
125
|
+
comment = CukeModeler::FeatureFile.new(test_file_path).comments.first
|
125
126
|
|
126
127
|
expect(comment.source_line).to eq(1)
|
127
128
|
end
|
@@ -21,52 +21,48 @@ describe 'Directory, Integration' do
|
|
21
21
|
|
22
22
|
context 'with an existing directory' do
|
23
23
|
|
24
|
-
let(:
|
25
|
-
let(:directory) { clazz.new(directory_path) }
|
24
|
+
let(:root_test_path) { CukeModeler::FileHelper.create_directory }
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'nested_directory', :directory => root_test_path) }
|
27
|
+
let(:directory_model) { clazz.new(directory_path) }
|
30
28
|
|
31
29
|
|
32
30
|
it 'models the path of the directory' do
|
33
|
-
expect(
|
31
|
+
expect(directory_model.path).to eq(directory_path)
|
34
32
|
end
|
35
33
|
|
36
34
|
it 'models the name of the directory' do
|
37
35
|
name = File.basename(directory_path)
|
38
36
|
|
39
|
-
expect(
|
37
|
+
expect(directory_model.name).to eq(name)
|
40
38
|
end
|
41
39
|
|
42
40
|
|
43
41
|
context 'with both files and feature files' do
|
44
42
|
|
45
|
-
let(:feature_files) { ['test_file_1
|
46
|
-
let(:non_feature_files) { ['
|
43
|
+
let(:feature_files) { ['test_file_1', 'test_file_2'] }
|
44
|
+
let(:non_feature_files) { ['test_file_3'] }
|
47
45
|
|
48
46
|
before(:each) do
|
49
47
|
feature_files.each do |file_name|
|
50
48
|
# Some versions of Gherkin require feature content to be present in feature files
|
51
|
-
|
52
|
-
file.puts("#{@feature_keyword}: Test feature")
|
53
|
-
}
|
49
|
+
CukeModeler::FileHelper.create_feature_file(:text => "#{@feature_keyword}: Test feature", :name => file_name, :directory => directory_path)
|
54
50
|
end
|
55
51
|
|
56
52
|
non_feature_files.each do |file_name|
|
57
|
-
|
53
|
+
CukeModeler::FileHelper.create_file(:text => '', :name => file_name, :extension => '.file', :directory => directory_path)
|
58
54
|
end
|
59
55
|
end
|
60
56
|
|
61
57
|
|
62
58
|
it 'models the feature files contained in the directory' do
|
63
|
-
modeled_files =
|
59
|
+
modeled_files = directory_model.feature_files.collect { |file| file.name[/test_file_\d/] }
|
64
60
|
|
65
61
|
expect(modeled_files).to match_array(feature_files)
|
66
62
|
end
|
67
63
|
|
68
64
|
it 'does not model non-feature files contained in the directory' do
|
69
|
-
modeled_files =
|
65
|
+
modeled_files = directory_model.feature_files.collect { |file| file.name[/test_file_\d/] }
|
70
66
|
|
71
67
|
non_feature_files.all? do |file|
|
72
68
|
expect(modeled_files).to_not include(file)
|
@@ -78,13 +74,12 @@ describe 'Directory, Integration' do
|
|
78
74
|
|
79
75
|
context 'with no feature files' do
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
end
|
77
|
+
let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'empty_directory', :directory => root_test_path) }
|
78
|
+
let(:directory_model) { clazz.new(directory_path) }
|
84
79
|
|
85
80
|
|
86
81
|
it 'models the feature files contained in the directory' do
|
87
|
-
modeled_files =
|
82
|
+
modeled_files = directory_model.feature_files.collect { |file| file.name }
|
88
83
|
|
89
84
|
expect(modeled_files).to eq([])
|
90
85
|
end
|
@@ -94,16 +89,20 @@ describe 'Directory, Integration' do
|
|
94
89
|
|
95
90
|
context 'with a nested directory' do
|
96
91
|
|
92
|
+
let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'test_directory', :directory => root_test_path) }
|
93
|
+
let(:directory_model) { clazz.new(directory_path) }
|
94
|
+
|
97
95
|
let(:nested_directories) { ['nested_directory_1', 'nested_directory_2'] }
|
98
96
|
|
99
97
|
before(:each) do
|
100
98
|
nested_directories.each do |nested_directory|
|
101
|
-
|
99
|
+
CukeModeler::FileHelper.create_directory(:name => nested_directory, :directory => directory_path)
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
103
|
+
|
105
104
|
it 'models the directories in the directory' do
|
106
|
-
modeled_directories =
|
105
|
+
modeled_directories = directory_model.directories.collect { |nested_directory| nested_directory.name[/nested_directory_\d/] }
|
107
106
|
|
108
107
|
expect(modeled_directories).to match_array(nested_directories)
|
109
108
|
end
|
@@ -113,13 +112,12 @@ describe 'Directory, Integration' do
|
|
113
112
|
|
114
113
|
context 'with no directories' do
|
115
114
|
|
116
|
-
|
117
|
-
|
118
|
-
end
|
115
|
+
let(:directory_path) { CukeModeler::FileHelper.create_directory(:name => 'empty_directory', :directory => root_test_path) }
|
116
|
+
let(:directory_model) { clazz.new(directory_path) }
|
119
117
|
|
120
118
|
|
121
119
|
it 'models the directories contained in the directory' do
|
122
|
-
modeled_directories =
|
120
|
+
modeled_directories = directory_model.directories.collect { |nested_directory| nested_directory.name }
|
123
121
|
|
124
122
|
expect(modeled_directories).to eq([])
|
125
123
|
end
|
@@ -131,11 +129,8 @@ describe 'Directory, Integration' do
|
|
131
129
|
|
132
130
|
context 'with a non-existing directory' do
|
133
131
|
|
134
|
-
let(:
|
135
|
-
|
136
|
-
before(:each) do
|
137
|
-
FileUtils.remove_dir(directory_path, true)
|
138
|
-
end
|
132
|
+
let(:root_test_path) { CukeModeler::FileHelper.create_directory }
|
133
|
+
let(:directory_path) { "#{root_test_path}/this_directory_should_not_exist" }
|
139
134
|
|
140
135
|
|
141
136
|
it 'cannot model a non-existent directory' do
|
@@ -148,41 +143,41 @@ describe 'Directory, Integration' do
|
|
148
143
|
|
149
144
|
|
150
145
|
it 'properly sets its child models' do
|
151
|
-
|
152
|
-
|
146
|
+
directory_path = CukeModeler::FileHelper.create_directory
|
147
|
+
_nested_directory_path = CukeModeler::FileHelper.create_directory(:name => 'nested_directory', :directory => directory_path)
|
148
|
+
|
149
|
+
CukeModeler::FileHelper.create_feature_file(:text => "#{@feature_keyword}: Test feature", :name => 'test_file', :directory => directory_path)
|
153
150
|
|
154
|
-
FileUtils.mkdir(nested_directory)
|
155
|
-
File.open(file_path, "w") { |file|
|
156
|
-
file.puts("#{@feature_keyword}: Test feature")
|
157
|
-
}
|
158
151
|
|
159
|
-
|
160
|
-
|
161
|
-
|
152
|
+
directory_model = clazz.new(directory_path)
|
153
|
+
nested_directory_model = directory_model.directories.first
|
154
|
+
file_model = directory_model.feature_files.first
|
162
155
|
|
163
|
-
expect(
|
164
|
-
expect(
|
156
|
+
expect(nested_directory_model.parent_model).to equal(directory_model)
|
157
|
+
expect(file_model.parent_model).to equal(directory_model)
|
165
158
|
end
|
166
159
|
|
167
160
|
|
168
161
|
describe 'getting ancestors' do
|
169
162
|
|
170
163
|
before(:each) do
|
171
|
-
|
164
|
+
CukeModeler::FileHelper.create_directory(:name => 'nested_directory', :directory => test_directory)
|
172
165
|
end
|
173
166
|
|
174
|
-
let(:
|
175
|
-
|
167
|
+
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
168
|
+
|
169
|
+
let(:directory_model) { clazz.new(test_directory) }
|
170
|
+
let(:nested_directory_model) { directory_model.directories.first }
|
176
171
|
|
177
172
|
|
178
173
|
it 'can get its directory' do
|
179
|
-
ancestor =
|
174
|
+
ancestor = nested_directory_model.get_ancestor(:directory)
|
180
175
|
|
181
|
-
expect(ancestor).to equal(
|
176
|
+
expect(ancestor).to equal(directory_model)
|
182
177
|
end
|
183
178
|
|
184
179
|
it 'returns nil if it does not have the requested type of ancestor' do
|
185
|
-
ancestor =
|
180
|
+
ancestor = nested_directory_model.get_ancestor(:example)
|
186
181
|
|
187
182
|
expect(ancestor).to be_nil
|
188
183
|
end
|
@@ -194,16 +189,12 @@ describe 'Directory, Integration' do
|
|
194
189
|
|
195
190
|
context 'from source text' do
|
196
191
|
|
197
|
-
let(:directory_path) {
|
198
|
-
let(:
|
199
|
-
|
200
|
-
before(:each) do
|
201
|
-
FileUtils.mkdir(directory_path)
|
202
|
-
end
|
192
|
+
let(:directory_path) { CukeModeler::FileHelper.create_directory }
|
193
|
+
let(:directory_model) { clazz.new(directory_path) }
|
203
194
|
|
204
195
|
|
205
196
|
it 'can output a directory' do
|
206
|
-
directory_output =
|
197
|
+
directory_output = directory_model.to_s
|
207
198
|
|
208
199
|
expect(directory_output).to eq(directory_path)
|
209
200
|
end
|
@@ -211,7 +202,7 @@ describe 'Directory, Integration' do
|
|
211
202
|
end
|
212
203
|
|
213
204
|
it 'can be remade from its own output' do
|
214
|
-
source =
|
205
|
+
source = CukeModeler::FileHelper.create_directory
|
215
206
|
directory = clazz.new(source)
|
216
207
|
|
217
208
|
directory_output = directory.to_s
|
@@ -80,140 +80,133 @@ describe 'DocString, Integration' do
|
|
80
80
|
describe 'getting ancestors' do
|
81
81
|
|
82
82
|
before(:each) do
|
83
|
-
|
84
|
-
|
85
|
-
#{@scenario_keyword}: Test test
|
86
|
-
#{@step_keyword} a big step:
|
87
|
-
\"\"\"
|
88
|
-
a
|
89
|
-
doc
|
90
|
-
string
|
91
|
-
\"\"\""
|
92
|
-
|
93
|
-
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
94
|
-
File.open(file_path, 'w') { |file| file.write(source) }
|
83
|
+
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'doc_string_test_file', :directory => test_directory)
|
95
84
|
end
|
96
85
|
|
97
|
-
|
98
|
-
let(:
|
86
|
+
|
87
|
+
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
88
|
+
let(:source_gherkin) { "#{@feature_keyword}: Test feature
|
89
|
+
|
90
|
+
#{@scenario_keyword}: Test test
|
91
|
+
#{@step_keyword} a big step:
|
92
|
+
\"\"\"
|
93
|
+
a
|
94
|
+
doc
|
95
|
+
string
|
96
|
+
\"\"\""
|
97
|
+
}
|
98
|
+
|
99
|
+
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
100
|
+
let(:doc_string_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
|
99
101
|
|
100
102
|
|
101
103
|
it 'can get its directory' do
|
102
|
-
ancestor =
|
104
|
+
ancestor = doc_string_model.get_ancestor(:directory)
|
103
105
|
|
104
|
-
expect(ancestor).to equal(
|
106
|
+
expect(ancestor).to equal(directory_model)
|
105
107
|
end
|
106
108
|
|
107
109
|
it 'can get its feature file' do
|
108
|
-
ancestor =
|
110
|
+
ancestor = doc_string_model.get_ancestor(:feature_file)
|
109
111
|
|
110
|
-
expect(ancestor).to equal(
|
112
|
+
expect(ancestor).to equal(directory_model.feature_files.first)
|
111
113
|
end
|
112
114
|
|
113
115
|
it 'can get its feature' do
|
114
|
-
ancestor =
|
116
|
+
ancestor = doc_string_model.get_ancestor(:feature)
|
115
117
|
|
116
|
-
expect(ancestor).to equal(
|
118
|
+
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
117
119
|
end
|
118
120
|
|
119
121
|
context 'a doc string that is part of a scenario' do
|
120
122
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
133
|
-
File.open(file_path, 'w') { |file| file.write(source) }
|
134
|
-
end
|
123
|
+
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
124
|
+
let(:source_gherkin) { "#{@feature_keyword}: Test feature
|
125
|
+
|
126
|
+
#{@scenario_keyword}: Test test
|
127
|
+
#{@step_keyword} a big step:
|
128
|
+
\"\"\"
|
129
|
+
a
|
130
|
+
doc
|
131
|
+
string
|
132
|
+
\"\"\""
|
133
|
+
}
|
135
134
|
|
136
|
-
let(:
|
137
|
-
let(:
|
135
|
+
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
136
|
+
let(:doc_string_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
|
138
137
|
|
139
138
|
|
140
139
|
it 'can get its scenario' do
|
141
|
-
ancestor =
|
140
|
+
ancestor = doc_string_model.get_ancestor(:scenario)
|
142
141
|
|
143
|
-
expect(ancestor).to equal(
|
142
|
+
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
144
143
|
end
|
145
144
|
|
146
145
|
end
|
147
146
|
|
148
147
|
context 'a doc string that is part of an outline' do
|
149
148
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
165
|
-
File.open(file_path, 'w') { |file| file.write(source) }
|
166
|
-
end
|
149
|
+
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
150
|
+
let(:source_gherkin) { "#{@feature_keyword}: Test feature
|
151
|
+
|
152
|
+
#{@outline_keyword}: Test outline
|
153
|
+
#{@step_keyword} a big step:
|
154
|
+
\"\"\"
|
155
|
+
a
|
156
|
+
doc
|
157
|
+
string
|
158
|
+
\"\"\"
|
159
|
+
#{@example_keyword}:
|
160
|
+
| param |
|
161
|
+
| value |"
|
162
|
+
}
|
167
163
|
|
168
|
-
let(:
|
169
|
-
let(:
|
164
|
+
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
165
|
+
let(:doc_string_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
|
170
166
|
|
171
167
|
|
172
168
|
it 'can get its outline' do
|
173
|
-
ancestor =
|
169
|
+
ancestor = doc_string_model.get_ancestor(:outline)
|
174
170
|
|
175
|
-
expect(ancestor).to equal(
|
171
|
+
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
176
172
|
end
|
177
173
|
|
178
174
|
end
|
179
175
|
|
180
176
|
context 'a doc string that is part of a background' do
|
181
177
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
194
|
-
File.open(file_path, 'w') { |file| file.write(source) }
|
195
|
-
end
|
178
|
+
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
179
|
+
let(:source_gherkin) { "#{@feature_keyword}: Test feature
|
180
|
+
|
181
|
+
#{@background_keyword}: Test background
|
182
|
+
#{@step_keyword} a big step:
|
183
|
+
\"\"\"
|
184
|
+
a
|
185
|
+
doc
|
186
|
+
string
|
187
|
+
\"\"\""
|
188
|
+
}
|
196
189
|
|
197
|
-
let(:
|
198
|
-
let(:
|
190
|
+
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
191
|
+
let(:doc_string_model) { directory_model.feature_files.first.feature.background.steps.first.block }
|
199
192
|
|
200
193
|
|
201
194
|
it 'can get its background' do
|
202
|
-
ancestor =
|
195
|
+
ancestor = doc_string_model.get_ancestor(:background)
|
203
196
|
|
204
|
-
expect(ancestor).to equal(
|
197
|
+
expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
|
205
198
|
end
|
206
199
|
|
207
200
|
end
|
208
201
|
|
209
202
|
it 'can get its step' do
|
210
|
-
ancestor =
|
203
|
+
ancestor = doc_string_model.get_ancestor(:step)
|
211
204
|
|
212
|
-
expect(ancestor).to equal(
|
205
|
+
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
|
213
206
|
end
|
214
207
|
|
215
208
|
it 'returns nil if it does not have the requested type of ancestor' do
|
216
|
-
ancestor =
|
209
|
+
ancestor = doc_string_model.get_ancestor(:example)
|
217
210
|
|
218
211
|
expect(ancestor).to be_nil
|
219
212
|
end
|