cuke_modeler 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +1 -2
  3. data/.travis.yml +4 -3
  4. data/Gemfile +1 -1
  5. data/History.md +5 -0
  6. data/README.md +2 -1
  7. data/Rakefile +19 -0
  8. data/appveyor.yml +19 -18
  9. data/cuke_modeler.gemspec +1 -1
  10. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +1 -1
  11. data/lib/cuke_modeler/parsing.rb +1 -1
  12. data/lib/cuke_modeler/version.rb +1 -1
  13. data/testing/cucumber/features/analysis/test_comparison.feature +1 -4
  14. data/testing/cucumber/features/modeling/background_modeling.feature +1 -2
  15. data/testing/cucumber/features/modeling/background_output.feature +1 -2
  16. data/testing/cucumber/features/modeling/cell_modeling.feature +1 -2
  17. data/testing/cucumber/features/modeling/comment_modeling.feature +1 -2
  18. data/testing/cucumber/features/modeling/comment_output.feature +1 -2
  19. data/testing/cucumber/features/modeling/directory_modeling.feature +1 -4
  20. data/testing/cucumber/features/modeling/directory_output.feature +1 -2
  21. data/testing/cucumber/features/modeling/doc_string_modeling.feature +1 -3
  22. data/testing/cucumber/features/modeling/doc_string_output.feature +1 -2
  23. data/testing/cucumber/features/modeling/example_modeling.feature +1 -3
  24. data/testing/cucumber/features/modeling/example_output.feature +1 -2
  25. data/testing/cucumber/features/modeling/feature_file_modeling.feature +1 -3
  26. data/testing/cucumber/features/modeling/feature_file_output.feature +1 -2
  27. data/testing/cucumber/features/modeling/feature_modeling.feature +2 -5
  28. data/testing/cucumber/features/modeling/feature_output.feature +1 -2
  29. data/testing/cucumber/features/modeling/model_output.feature +1 -3
  30. data/testing/cucumber/features/modeling/model_structure.feature +3 -9
  31. data/testing/cucumber/features/modeling/outline_modeling.feature +1 -2
  32. data/testing/cucumber/features/modeling/outline_output.feature +1 -2
  33. data/testing/cucumber/features/modeling/row_modeling.feature +1 -2
  34. data/testing/cucumber/features/modeling/row_output.feature +1 -2
  35. data/testing/cucumber/features/modeling/scenario_modeling.feature +1 -2
  36. data/testing/cucumber/features/modeling/scenario_output.feature +1 -2
  37. data/testing/cucumber/features/modeling/step_modeling.feature +1 -2
  38. data/testing/cucumber/features/modeling/step_output.feature +1 -2
  39. data/testing/cucumber/features/modeling/table_modeling.feature +1 -2
  40. data/testing/cucumber/features/modeling/table_output.feature +1 -2
  41. data/testing/cucumber/features/modeling/tag_modeling.feature +1 -2
  42. data/testing/cucumber/features/modeling/tag_output.feature +1 -2
  43. data/testing/cucumber/step_definitions/directory_steps.rb +1 -1
  44. data/testing/cucumber/step_definitions/feature_file_steps.rb +1 -1
  45. data/testing/cucumber/step_definitions/modeling_steps.rb +1 -1
  46. data/testing/cucumber/step_definitions/setup_steps.rb +4 -6
  47. data/testing/cucumber/step_definitions/verification_steps.rb +3 -3
  48. data/testing/cucumber/support/env.rb +7 -14
  49. data/testing/file_helper.rb +44 -0
  50. data/testing/gemfiles/gherkin5.gemfile +20 -0
  51. data/testing/rspec/spec/integration/background_integration_spec.rb +17 -15
  52. data/testing/rspec/spec/integration/cell_integration_spec.rb +69 -79
  53. data/testing/rspec/spec/integration/comment_integration_spec.rb +16 -15
  54. data/testing/rspec/spec/integration/directory_integration_spec.rb +46 -55
  55. data/testing/rspec/spec/integration/doc_string_integration_spec.rb +73 -80
  56. data/testing/rspec/spec/integration/example_integration_spec.rb +53 -36
  57. data/testing/rspec/spec/integration/feature_file_integration_spec.rb +27 -42
  58. data/testing/rspec/spec/integration/feature_integration_spec.rb +12 -11
  59. data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +14 -16
  60. data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +14 -16
  61. data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +14 -16
  62. data/testing/rspec/spec/integration/outline_integration_spec.rb +20 -18
  63. data/testing/rspec/spec/integration/parsing_integration_spec.rb +1 -1
  64. data/testing/rspec/spec/integration/row_integration_spec.rb +57 -64
  65. data/testing/rspec/spec/integration/scenario_integration_spec.rb +17 -15
  66. data/testing/rspec/spec/integration/step_integration_spec.rb +48 -55
  67. data/testing/rspec/spec/integration/table_integration_spec.rb +54 -61
  68. data/testing/rspec/spec/integration/tag_integration_spec.rb +61 -67
  69. data/testing/rspec/spec/spec_helper.rb +5 -16
  70. data/testing/rspec/spec/unit/background_unit_spec.rb +0 -5
  71. data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -5
  72. data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -6
  73. data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -5
  74. data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -5
  75. data/testing/rspec/spec/unit/example_unit_spec.rb +0 -5
  76. data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -5
  77. data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -5
  78. data/testing/rspec/spec/unit/outline_unit_spec.rb +0 -5
  79. data/testing/rspec/spec/unit/row_unit_spec.rb +0 -5
  80. data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -5
  81. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +1 -1
  82. data/testing/rspec/spec/unit/step_unit_spec.rb +0 -5
  83. data/testing/rspec/spec/unit/table_unit_spec.rb +0 -5
  84. data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -5
  85. data/todo.txt +0 -4
  86. 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
- source = "# feature comment
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
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
82
- let(:comment) { directory.feature_files.first.comments.first }
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 = comment.get_ancestor(:directory)
88
+ ancestor = comment_model.get_ancestor(:directory)
87
89
 
88
- expect(ancestor).to equal(directory)
90
+ expect(ancestor).to equal(directory_model)
89
91
  end
90
92
 
91
93
  it 'can get its feature file' do
92
- ancestor = comment.get_ancestor(:feature_file)
94
+ ancestor = comment_model.get_ancestor(:feature_file)
93
95
 
94
- expect(ancestor).to equal(directory.feature_files.first)
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 = comment.get_ancestor(:example)
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
- File.open(path, "w") { |file| file.puts source_text }
124
- comment = CukeModeler::FeatureFile.new(path).comments.first
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(:directory_path) { "#{@default_file_directory}/test_directory" }
25
- let(:directory) { clazz.new(directory_path) }
24
+ let(:root_test_path) { CukeModeler::FileHelper.create_directory }
26
25
 
27
- before(:each) do
28
- FileUtils.mkdir(directory_path)
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(directory.path).to eq(directory_path)
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(directory.name).to eq(name)
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.feature', 'test_file_2.feature'] }
46
- let(:non_feature_files) { ['random.file'] }
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
- File.open("#{directory_path}/#{file_name}", "w") { |file|
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
- FileUtils.touch("#{directory_path}/#{file_name}")
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 = directory.feature_files.collect { |file| file.name }
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 = directory.feature_files.collect { |file| file.name }
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
- before(:each) do
82
- FileUtils.rm(Dir.glob("#{directory_path}/#{@step_keyword}"))
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 = directory.feature_files.collect { |file| file.name }
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
- FileUtils.mkdir("#{directory_path}/#{nested_directory}")
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 = directory.directories.collect { |nested_directory| nested_directory.name }
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
- before(:each) do
117
- FileUtils.rm_r(Dir.glob("#{directory_path}/#{@step_keyword}"))
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 = directory.directories.collect { |nested_directory| nested_directory.name }
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(:directory_path) { "#{@default_file_directory}/test_directory" }
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
- nested_directory = "#{@default_file_directory}/nested_directory"
152
- file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
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
- directory = clazz.new(@default_file_directory)
160
- nested_directory = directory.directories.first
161
- file = directory.feature_files.first
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(nested_directory.parent_model).to equal(directory)
164
- expect(file.parent_model).to equal(directory)
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
- FileUtils.mkdir("#{@default_file_directory}/nested_directory")
164
+ CukeModeler::FileHelper.create_directory(:name => 'nested_directory', :directory => test_directory)
172
165
  end
173
166
 
174
- let(:directory) { clazz.new(@default_file_directory) }
175
- let(:nested_directory) { directory.directories.first }
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 = nested_directory.get_ancestor(:directory)
174
+ ancestor = nested_directory_model.get_ancestor(:directory)
180
175
 
181
- expect(ancestor).to equal(directory)
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 = nested_directory.get_ancestor(:example)
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) { "#{@default_file_directory}/test_directory" }
198
- let(:directory) { clazz.new(directory_path) }
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 = directory.to_s
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 = @default_file_directory
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
- source = "#{@feature_keyword}: Test feature
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
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
98
- let(:doc_string) { directory.feature_files.first.feature.tests.first.steps.first.block }
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 = doc_string.get_ancestor(:directory)
104
+ ancestor = doc_string_model.get_ancestor(:directory)
103
105
 
104
- expect(ancestor).to equal(directory)
106
+ expect(ancestor).to equal(directory_model)
105
107
  end
106
108
 
107
109
  it 'can get its feature file' do
108
- ancestor = doc_string.get_ancestor(:feature_file)
110
+ ancestor = doc_string_model.get_ancestor(:feature_file)
109
111
 
110
- expect(ancestor).to equal(directory.feature_files.first)
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 = doc_string.get_ancestor(:feature)
116
+ ancestor = doc_string_model.get_ancestor(:feature)
115
117
 
116
- expect(ancestor).to equal(directory.feature_files.first.feature)
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
- before(:each) do
122
- source = "#{@feature_keyword}: Test feature
123
-
124
- #{@scenario_keyword}: Test test
125
- #{@step_keyword} a big step:
126
- \"\"\"
127
- a
128
- doc
129
- string
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(:directory) { CukeModeler::Directory.new(@default_file_directory) }
137
- let(:doc_string) { directory.feature_files.first.feature.tests.first.steps.first.block }
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 = doc_string.get_ancestor(:scenario)
140
+ ancestor = doc_string_model.get_ancestor(:scenario)
142
141
 
143
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
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
- before(:each) do
151
- source = "#{@feature_keyword}: Test feature
152
-
153
- #{@outline_keyword}: Test outline
154
- #{@step_keyword} a big step:
155
- \"\"\"
156
- a
157
- doc
158
- string
159
- \"\"\"
160
- #{@example_keyword}:
161
- | param |
162
- | value |"
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(:directory) { CukeModeler::Directory.new(@default_file_directory) }
169
- let(:doc_string) { directory.feature_files.first.feature.tests.first.steps.first.block }
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 = doc_string.get_ancestor(:outline)
169
+ ancestor = doc_string_model.get_ancestor(:outline)
174
170
 
175
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
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
- before(:each) do
183
- source = "#{@feature_keyword}: Test feature
184
-
185
- #{@background_keyword}: Test background
186
- #{@step_keyword} a big step:
187
- \"\"\"
188
- a
189
- doc
190
- string
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(:directory) { CukeModeler::Directory.new(@default_file_directory) }
198
- let(:doc_string) { directory.feature_files.first.feature.background.steps.first.block }
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 = doc_string.get_ancestor(:background)
195
+ ancestor = doc_string_model.get_ancestor(:background)
203
196
 
204
- expect(ancestor).to equal(directory.feature_files.first.feature.background)
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 = doc_string.get_ancestor(:step)
203
+ ancestor = doc_string_model.get_ancestor(:step)
211
204
 
212
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.steps.first)
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 = doc_string.get_ancestor(:example)
209
+ ancestor = doc_string_model.get_ancestor(:example)
217
210
 
218
211
  expect(ancestor).to be_nil
219
212
  end