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
@@ -67,42 +67,40 @@ describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
67
67
  | param |
68
68
  | value |
69
69
  # final comment" }
70
- let(:feature_file) { path = "#{@default_file_directory}/#{@default_feature_file_name}"
71
- File.open(path, "w") { |file| file.puts source_text }
72
-
73
- CukeModeler::FeatureFile.new(path) }
74
- let(:feature) { feature_file.feature }
70
+ let(:feature_file_model) { test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'adapter_test_file')
71
+ CukeModeler::FeatureFile.new(test_file_path) }
72
+ let(:feature_model) { feature_file_model.feature }
75
73
 
76
74
 
77
75
  it "does not store parsing data for a feature file's children" do
78
- model = feature_file
76
+ model = feature_file_model
79
77
 
80
78
  expect(model.parsing_data[:comments]).to be_nil
81
79
  expect(model.parsing_data[:feature]).to be_nil
82
80
  end
83
81
 
84
82
  it "does not store parsing data for a feature's children" do
85
- model = feature
83
+ model = feature_model
86
84
 
87
85
  expect(model.parsing_data[:tags]).to be_nil
88
86
  expect(model.parsing_data[:children]).to be_nil
89
87
  end
90
88
 
91
89
  it "does not store parsing data for a background's children" do
92
- model = feature.background
90
+ model = feature_model.background
93
91
 
94
92
  expect(model.parsing_data[:steps]).to be_nil
95
93
  end
96
94
 
97
95
  it "does not store parsing data for a scenario's children" do
98
- model = feature.scenarios.first
96
+ model = feature_model.scenarios.first
99
97
 
100
98
  expect(model.parsing_data[:tags]).to be_nil
101
99
  expect(model.parsing_data[:steps]).to be_nil
102
100
  end
103
101
 
104
102
  it "does not store parsing data for an outline's children" do
105
- model = feature.outlines.first
103
+ model = feature_model.outlines.first
106
104
 
107
105
  expect(model.parsing_data[:tags]).to be_nil
108
106
  expect(model.parsing_data[:steps]).to be_nil
@@ -110,7 +108,7 @@ describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
110
108
  end
111
109
 
112
110
  it "does not store parsing data for an example's children" do
113
- model = feature.outlines.first.examples.first
111
+ model = feature_model.outlines.first.examples.first
114
112
 
115
113
  expect(model.parsing_data[:tags]).to be_nil
116
114
  expect(model.parsing_data[:tableHeader]).to be_nil
@@ -118,31 +116,31 @@ describe 'Gherkin4Adapter, Integration', :gherkin4 => true do
118
116
  end
119
117
 
120
118
  it "does not store parsing data for an example row's children" do
121
- model = feature.outlines.first.examples.first.rows.first
119
+ model = feature_model.outlines.first.examples.first.rows.first
122
120
 
123
121
  expect(model.parsing_data[:cells]).to be_nil
124
122
  end
125
123
 
126
124
  it "does not store parsing data for a step's children, table" do
127
- model = feature.outlines.first.steps.first
125
+ model = feature_model.outlines.first.steps.first
128
126
 
129
127
  expect(model.parsing_data[:argument]).to be_nil
130
128
  end
131
129
 
132
130
  it "does not store parsing data for a step's children, doc string" do
133
- model = feature.outlines.first.steps.last
131
+ model = feature_model.outlines.first.steps.last
134
132
 
135
133
  expect(model.parsing_data[:argument]).to be_nil
136
134
  end
137
135
 
138
136
  it "does not store parsing data for a table's children" do
139
- model = feature.outlines.first.steps.first.block
137
+ model = feature_model.outlines.first.steps.first.block
140
138
 
141
139
  expect(model.parsing_data[:rows]).to be_nil
142
140
  end
143
141
 
144
142
  it "does not store parsing data for a table row's children" do
145
- model = feature.outlines.first.steps.first.block.rows.first
143
+ model = feature_model.outlines.first.steps.first.block.rows.first
146
144
 
147
145
  expect(model.parsing_data[:cells]).to be_nil
148
146
  end
@@ -108,42 +108,44 @@ describe 'Outline, Integration' do
108
108
  describe 'getting ancestors' do
109
109
 
110
110
  before(:each) do
111
- source = "#{@feature_keyword}: Test feature
111
+ CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'outline_test_file', :directory => test_directory)
112
+ end
112
113
 
113
- #{@outline_keyword}: Test test
114
- #{@step_keyword} a step
115
- #{@example_keyword}: Test example
116
- | a param |
117
- | a value |"
118
114
 
119
- file_path = "#{@default_file_directory}/outline_test_file.feature"
120
- File.open(file_path, 'w') { |file| file.write(source) }
121
- end
115
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
116
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
117
+
118
+ #{@outline_keyword}: Test test
119
+ #{@step_keyword} a step
120
+ #{@example_keyword}: Test example
121
+ | a param |
122
+ | a value |"
123
+ }
122
124
 
123
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
124
- let(:outline) { directory.feature_files.first.feature.tests.first }
125
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
126
+ let(:outline_model) { directory_model.feature_files.first.feature.tests.first }
125
127
 
126
128
 
127
129
  it 'can get its directory' do
128
- ancestor = outline.get_ancestor(:directory)
130
+ ancestor = outline_model.get_ancestor(:directory)
129
131
 
130
- expect(ancestor).to equal(directory)
132
+ expect(ancestor).to equal(directory_model)
131
133
  end
132
134
 
133
135
  it 'can get its feature file' do
134
- ancestor = outline.get_ancestor(:feature_file)
136
+ ancestor = outline_model.get_ancestor(:feature_file)
135
137
 
136
- expect(ancestor).to equal(directory.feature_files.first)
138
+ expect(ancestor).to equal(directory_model.feature_files.first)
137
139
  end
138
140
 
139
141
  it 'can get its feature' do
140
- ancestor = outline.get_ancestor(:feature)
142
+ ancestor = outline_model.get_ancestor(:feature)
141
143
 
142
- expect(ancestor).to equal(directory.feature_files.first.feature)
144
+ expect(ancestor).to equal(directory_model.feature_files.first.feature)
143
145
  end
144
146
 
145
147
  it 'returns nil if it does not have the requested type of ancestor' do
146
- ancestor = outline.get_ancestor(:test)
148
+ ancestor = outline_model.get_ancestor(:test)
147
149
 
148
150
  expect(ancestor).to be_nil
149
151
  end
@@ -46,7 +46,7 @@ describe 'Parsing, Integration' do
46
46
  expect { nodule.parse_text(:not_a_string) }.to raise_error(ArgumentError, /Symbol/)
47
47
  end
48
48
 
49
- # todo - Stop doing this. Just return a feature file rooted AST.
49
+ # todo - Stop doing this. Just return a feature file rooted AST. (Will require major version number change)
50
50
  it 'returns an Array' do
51
51
  result = nodule.parse_text("#{@feature_keyword}:")
52
52
  expect(result).to be_a(Array)
@@ -83,71 +83,70 @@ describe 'Row, Integration' do
83
83
  describe 'getting ancestors' do
84
84
 
85
85
  before(:each) do
86
- source = "#{@feature_keyword}: Test feature
86
+ CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'row_test_file', :directory => test_directory)
87
+ end
87
88
 
88
- #{@scenario_keyword}: Test test
89
- #{@step_keyword} a step:
90
- | a | table |"
91
89
 
92
- file_path = "#{@default_file_directory}/row_test_file.feature"
93
- File.open(file_path, 'w') { |file| file.write(source) }
94
- end
90
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
91
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
92
+
93
+ #{@scenario_keyword}: Test test
94
+ #{@step_keyword} a step:
95
+ | a | table |"
96
+ }
95
97
 
96
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
97
- let(:row) { directory.feature_files.first.feature.tests.first.steps.first.block.rows.first }
98
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
99
+ let(:row_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first }
98
100
 
99
101
 
100
102
  it 'can get its directory' do
101
- ancestor = row.get_ancestor(:directory)
103
+ ancestor = row_model.get_ancestor(:directory)
102
104
 
103
- expect(ancestor).to equal(directory)
105
+ expect(ancestor).to equal(directory_model)
104
106
  end
105
107
 
106
108
  it 'can get its feature file' do
107
- ancestor = row.get_ancestor(:feature_file)
109
+ ancestor = row_model.get_ancestor(:feature_file)
108
110
 
109
- expect(ancestor).to equal(directory.feature_files.first)
111
+ expect(ancestor).to equal(directory_model.feature_files.first)
110
112
  end
111
113
 
112
114
  it 'can get its feature' do
113
- ancestor = row.get_ancestor(:feature)
115
+ ancestor = row_model.get_ancestor(:feature)
114
116
 
115
- expect(ancestor).to equal(directory.feature_files.first.feature)
117
+ expect(ancestor).to equal(directory_model.feature_files.first.feature)
116
118
  end
117
119
 
118
120
  it 'can get its step' do
119
- ancestor = row.get_ancestor(:step)
121
+ ancestor = row_model.get_ancestor(:step)
120
122
 
121
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.steps.first)
123
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
122
124
  end
123
125
 
124
126
  it 'can get its table' do
125
- ancestor = row.get_ancestor(:table)
127
+ ancestor = row_model.get_ancestor(:table)
126
128
 
127
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.steps.first.block)
129
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block)
128
130
  end
129
131
 
130
132
  context 'a row that is part of a scenario' do
131
133
 
132
- before(:each) do
133
- source = "#{@feature_keyword}: Test feature
134
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
135
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
134
136
 
135
- #{@scenario_keyword}: Test test
136
- #{@step_keyword} a step:
137
- | a | table |"
138
-
139
- file_path = "#{@default_file_directory}/row_test_file.feature"
140
- File.open(file_path, 'w') { |file| file.write(source) }
141
- end
137
+ #{@scenario_keyword}: Test test
138
+ #{@step_keyword} a step:
139
+ | a | table |"
140
+ }
142
141
 
143
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
144
- let(:row) { directory.feature_files.first.feature.tests.first.steps.first.block.rows.first }
142
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
143
+ let(:row_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first }
145
144
 
146
145
 
147
146
  it 'can get its scenario' do
148
- ancestor = row.get_ancestor(:scenario)
147
+ ancestor = row_model.get_ancestor(:scenario)
149
148
 
150
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
149
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
151
150
  end
152
151
 
153
152
  end
@@ -155,64 +154,58 @@ describe 'Row, Integration' do
155
154
 
156
155
  context 'a row that is part of a background' do
157
156
 
158
- before(:each) do
159
- source = "#{@feature_keyword}: Test feature
157
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
158
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
160
159
 
161
- #{@background_keyword}: Test background
162
- #{@step_keyword} a step:
163
- | a | table |"
160
+ #{@background_keyword}: Test background
161
+ #{@step_keyword} a step:
162
+ | a | table |"
163
+ }
164
164
 
165
- file_path = "#{@default_file_directory}/row_test_file.feature"
166
- File.open(file_path, 'w') { |file| file.write(source) }
167
- end
168
-
169
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
170
- let(:row) { directory.feature_files.first.feature.background.steps.first.block.rows.first }
165
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
166
+ let(:row_model) { directory_model.feature_files.first.feature.background.steps.first.block.rows.first }
171
167
 
172
168
 
173
169
  it 'can get its background' do
174
- ancestor = row.get_ancestor(:background)
170
+ ancestor = row_model.get_ancestor(:background)
175
171
 
176
- expect(ancestor).to equal(directory.feature_files.first.feature.background)
172
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
177
173
  end
178
174
 
179
175
  end
180
176
 
181
177
  context 'a row that is part of an outline' do
182
178
 
183
- before(:each) do
184
- source = "#{@feature_keyword}: Test feature
185
-
186
- #{@outline_keyword}: Test outline
187
- #{@step_keyword} a step
188
- #{@example_keyword}:
189
- | param |
190
- | value |"
191
-
192
- file_path = "#{@default_file_directory}/row_test_file.feature"
193
- File.open(file_path, 'w') { |file| file.write(source) }
194
- end
179
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
180
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
181
+
182
+ #{@outline_keyword}: Test outline
183
+ #{@step_keyword} a step
184
+ #{@example_keyword}:
185
+ | param |
186
+ | value |"
187
+ }
195
188
 
196
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
197
- let(:row) { directory.feature_files.first.feature.tests.first.examples.first.rows.first }
189
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
190
+ let(:row_model) { directory_model.feature_files.first.feature.tests.first.examples.first.rows.first }
198
191
 
199
192
 
200
193
  it 'can get its outline' do
201
- ancestor = row.get_ancestor(:outline)
194
+ ancestor = row_model.get_ancestor(:outline)
202
195
 
203
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
196
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
204
197
  end
205
198
 
206
199
  it 'can get its example' do
207
- ancestor = row.get_ancestor(:example)
200
+ ancestor = row_model.get_ancestor(:example)
208
201
 
209
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.examples.first)
202
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first)
210
203
  end
211
204
 
212
205
  end
213
206
 
214
207
  it 'returns nil if it does not have the requested type of ancestor' do
215
- ancestor = row.get_ancestor(:outline)
208
+ ancestor = row_model.get_ancestor(:outline)
216
209
 
217
210
  expect(ancestor).to be_nil
218
211
  end
@@ -106,39 +106,41 @@ describe 'Scenario, Integration' do
106
106
  describe 'getting ancestors' do
107
107
 
108
108
  before(:each) do
109
- source = "#{@feature_keyword}: Test feature
109
+ CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'scenario_test_file', :directory => test_directory)
110
+ end
110
111
 
111
- #{@scenario_keyword}: Test test
112
- #{@step_keyword} a step"
113
112
 
114
- file_path = "#{@default_file_directory}/scenario_test_file.feature"
115
- File.open(file_path, 'w') { |file| file.write(source) }
116
- end
113
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
114
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
115
+
116
+ #{@scenario_keyword}: Test test
117
+ #{@step_keyword} a step"
118
+ }
117
119
 
118
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
119
- let(:scenario) { directory.feature_files.first.feature.tests.first }
120
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
121
+ let(:scenario_model) { directory_model.feature_files.first.feature.tests.first }
120
122
 
121
123
 
122
124
  it 'can get its directory' do
123
- ancestor = scenario.get_ancestor(:directory)
125
+ ancestor = scenario_model.get_ancestor(:directory)
124
126
 
125
- expect(ancestor).to equal(directory)
127
+ expect(ancestor).to equal(directory_model)
126
128
  end
127
129
 
128
130
  it 'can get its feature file' do
129
- ancestor = scenario.get_ancestor(:feature_file)
131
+ ancestor = scenario_model.get_ancestor(:feature_file)
130
132
 
131
- expect(ancestor).to equal(directory.feature_files.first)
133
+ expect(ancestor).to equal(directory_model.feature_files.first)
132
134
  end
133
135
 
134
136
  it 'can get its feature' do
135
- ancestor = scenario.get_ancestor(:feature)
137
+ ancestor = scenario_model.get_ancestor(:feature)
136
138
 
137
- expect(ancestor).to equal(directory.feature_files.first.feature)
139
+ expect(ancestor).to equal(directory_model.feature_files.first.feature)
138
140
  end
139
141
 
140
142
  it 'returns nil if it does not have the requested type of ancestor' do
141
- ancestor = scenario.get_ancestor(:test)
143
+ ancestor = scenario_model.get_ancestor(:test)
142
144
 
143
145
  expect(ancestor).to be_nil
144
146
  end
@@ -244,115 +244,108 @@ describe 'Step, Integration' do
244
244
  describe 'getting ancestors' do
245
245
 
246
246
  before(:each) do
247
- source = "#{@feature_keyword}: Test feature
247
+ CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'step_test_file', :directory => test_directory)
248
+ end
248
249
 
249
- #{@scenario_keyword}: Test test
250
- #{@step_keyword} a step:"
251
250
 
252
- file_path = "#{@default_file_directory}/step_test_file.feature"
253
- File.open(file_path, 'w') { |file| file.write(source) }
254
- end
251
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
252
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
255
253
 
256
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
257
- let(:step) { directory.feature_files.first.feature.tests.first.steps.first }
254
+ #{@scenario_keyword}: Test test
255
+ #{@step_keyword} a step:"
256
+ }
257
+
258
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
259
+ let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
258
260
 
259
261
 
260
262
  it 'can get its directory' do
261
- ancestor = step.get_ancestor(:directory)
263
+ ancestor = step_model.get_ancestor(:directory)
262
264
 
263
- expect(ancestor).to equal(directory)
265
+ expect(ancestor).to equal(directory_model)
264
266
  end
265
267
 
266
268
  it 'can get its feature file' do
267
- ancestor = step.get_ancestor(:feature_file)
269
+ ancestor = step_model.get_ancestor(:feature_file)
268
270
 
269
- expect(ancestor).to equal(directory.feature_files.first)
271
+ expect(ancestor).to equal(directory_model.feature_files.first)
270
272
  end
271
273
 
272
274
  it 'can get its feature' do
273
- ancestor = step.get_ancestor(:feature)
275
+ ancestor = step_model.get_ancestor(:feature)
274
276
 
275
- expect(ancestor).to equal(directory.feature_files.first.feature)
277
+ expect(ancestor).to equal(directory_model.feature_files.first.feature)
276
278
  end
277
279
 
278
280
 
279
281
  context 'a step that is part of a scenario' do
280
282
 
281
- before(:each) do
282
- source = "#{@feature_keyword}: Test feature
283
-
284
- #{@scenario_keyword}: Test scenario
285
- #{@step_keyword} a step"
283
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
284
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
286
285
 
287
- file_path = "#{@default_file_directory}/step_test_file.feature"
288
- File.open(file_path, 'w') { |file| file.write(source) }
289
- end
286
+ #{@scenario_keyword}: Test scenario
287
+ #{@step_keyword} a step"
288
+ }
290
289
 
291
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
292
- let(:step) { directory.feature_files.first.feature.tests.first.steps.first }
290
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
291
+ let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
293
292
 
294
293
 
295
294
  it 'can get its scenario' do
296
- ancestor = step.get_ancestor(:scenario)
295
+ ancestor = step_model.get_ancestor(:scenario)
297
296
 
298
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
297
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
299
298
  end
300
299
 
301
300
  end
302
301
 
303
302
  context 'a step that is part of an outline' do
304
303
 
305
- before(:each) do
306
- source = "#{@feature_keyword}: Test feature
307
-
308
- #{@outline_keyword}: Test outline
309
- #{@step_keyword} a step
310
- #{@example_keyword}:
311
- | param |
312
- | value |"
313
-
314
- file_path = "#{@default_file_directory}/step_test_file.feature"
315
- File.open(file_path, 'w') { |file| file.write(source) }
316
- end
304
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
305
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
306
+
307
+ #{@outline_keyword}: Test outline
308
+ #{@step_keyword} a step
309
+ #{@example_keyword}:
310
+ | param |
311
+ | value |"
312
+ }
317
313
 
318
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
319
- let(:step) { directory.feature_files.first.feature.tests.first.steps.first }
314
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
315
+ let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
320
316
 
321
317
 
322
318
  it 'can get its outline' do
323
- ancestor = step.get_ancestor(:outline)
319
+ ancestor = step_model.get_ancestor(:outline)
324
320
 
325
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
321
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
326
322
  end
327
323
 
328
324
  end
329
325
 
330
326
  context 'a step that is part of a background' do
331
327
 
332
- before(:each) do
333
- source = "#{@feature_keyword}: Test feature
334
-
335
- #{@background_keyword}: Test background
336
- #{@step_keyword} a step"
328
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
329
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
337
330
 
338
- file_path = "#{@default_file_directory}/step_test_file.feature"
339
- File.open(file_path, 'w') { |file| file.write(source) }
340
- end
331
+ #{@background_keyword}: Test background
332
+ #{@step_keyword} a step"
333
+ }
341
334
 
342
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
343
- let(:step) { directory.feature_files.first.feature.background.steps.first }
335
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
336
+ let(:step_model) { directory_model.feature_files.first.feature.background.steps.first }
344
337
 
345
338
 
346
339
  it 'can get its background' do
347
- ancestor = step.get_ancestor(:background)
340
+ ancestor = step_model.get_ancestor(:background)
348
341
 
349
- expect(ancestor).to equal(directory.feature_files.first.feature.background)
342
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
350
343
  end
351
344
 
352
345
  end
353
346
 
354
347
  it 'returns nil if it does not have the requested type of ancestor' do
355
- ancestor = step.get_ancestor(:example)
348
+ ancestor = step_model.get_ancestor(:example)
356
349
 
357
350
  expect(ancestor).to be_nil
358
351
  end