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.
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
@@ -1,7 +1,6 @@
1
1
  Feature: Row output
2
2
 
3
- A row model's string output is a Gherkin representation of itself. As such, output from a row model can be used as
4
- input for the same kind of model.
3
+ A row model's string output is a Gherkin representation of itself. As such, output from a row model can be used as input for the same kind of model.
5
4
 
6
5
 
7
6
  Scenario: Outputting a row model
@@ -1,7 +1,6 @@
1
1
  Feature: Scenario modeling
2
2
 
3
- Scenario models represent a Scenario portion of a feature. They expose several attributes of the scenario
4
- that they represent, as well as containing models for the steps and tags that are present in that scenario.
3
+ Scenario models represent a Scenario portion of a feature. They expose several attributes of the scenario that they represent, as well as containing models for the steps and tags that are present in that scenario.
5
4
 
6
5
 
7
6
  Background:
@@ -1,7 +1,6 @@
1
1
  Feature: Scenario output
2
2
 
3
- A scenario model's string output is a Gherkin representation of itself. As such, output from a scenario model can be used as
4
- input for the same kind of model.
3
+ A scenario model's string output is a Gherkin representation of itself. As such, output from a scenario model can be used as input for the same kind of model.
5
4
 
6
5
 
7
6
  Scenario: Outputting a scenario model
@@ -1,7 +1,6 @@
1
1
  Feature: Step modeling
2
2
 
3
- Step models represent represent the a step in a scenario, outline, or background. They expose several attributes
4
- of the step that they represent.
3
+ Step models represent represent the a step in a scenario, outline, or background. They expose several attributes of the step that they represent.
5
4
 
6
5
 
7
6
  Background:
@@ -1,7 +1,6 @@
1
1
  Feature: Step output
2
2
 
3
- A step model's string output is a Gherkin representation of itself. As such, output from a step model can be used as
4
- input for the same kind of model.
3
+ A step model's string output is a Gherkin representation of itself. As such, output from a step model can be used as input for the same kind of model.
5
4
 
6
5
 
7
6
  Scenario: Outputting a step model
@@ -1,7 +1,6 @@
1
1
  Feature: Table modeling
2
2
 
3
- Table models represent represent the table argument to a step. They expose several attributes of the table
4
- that they represent.
3
+ Table models represent represent the table argument to a step. They expose several attributes of the table that they represent.
5
4
 
6
5
 
7
6
  Background:
@@ -1,7 +1,6 @@
1
1
  Feature: Table output
2
2
 
3
- A table model's string output is a Gherkin representation of itself. As such, output from a table model can be used as
4
- input for the same kind of model.
3
+ A table model's string output is a Gherkin representation of itself. As such, output from a table model can be used as input for the same kind of model.
5
4
 
6
5
 
7
6
  Scenario: Outputting a table model
@@ -1,7 +1,6 @@
1
1
  Feature: Tag modeling
2
2
 
3
- Tag models represent a tag portion of a feature. They expose several attributes of the tag
4
- that they represent.
3
+ Tag models represent a tag portion of a feature. They expose several attributes of the tag that they represent.
5
4
 
6
5
 
7
6
  Background:
@@ -1,7 +1,6 @@
1
1
  Feature: Tag output
2
2
 
3
- A tag model's string output is a Gherkin representation of itself. As such, output from a tag model can be used as
4
- input for the same kind of model.
3
+ A tag model's string output is a Gherkin representation of itself. As such, output from a tag model can be used as input for the same kind of model.
5
4
 
6
5
 
7
6
  Scenario: Outputting a tag model
@@ -1,5 +1,5 @@
1
1
  Given(/^a directory model based on "([^"]*)"$/) do |directory_name|
2
- directory_path = "#{@default_file_directory}/#{directory_name}"
2
+ directory_path = "#{@root_test_directory}/#{directory_name}"
3
3
  FileUtils.mkdir(directory_path) unless File.exists?(directory_path)
4
4
 
5
5
  @model = CukeModeler::Directory.new(directory_path)
@@ -1,5 +1,5 @@
1
1
  Given(/^a feature file model based on "([^"]*)"$/) do |file_name|
2
- file_path = "#{@default_file_directory}/#{file_name}"
2
+ file_path = "#{@root_test_directory}/#{file_name}"
3
3
  File.open(file_path, 'w') { |file| file.puts "Feature:" } unless File.exists?(file_path)
4
4
 
5
5
  @model = CukeModeler::FeatureFile.new(file_path)
@@ -19,7 +19,7 @@ And(/^a(?:n)? \w+(?: \w+)? model based on that gherkin$/) do |code_text|
19
19
  end
20
20
 
21
21
  Given(/^(?:a|the) (?:directory|feature file) is modeled$/) do |code_text|
22
- code_text.gsub!('<path_to>', @default_file_directory)
22
+ code_text.gsub!('<path_to>', @root_test_directory)
23
23
 
24
24
  eval(code_text)
25
25
  end
@@ -1,11 +1,11 @@
1
1
  Given /^(?:a|the) directory "([^"]*)"$/ do |directory_name|
2
- @test_directory = "#{@default_file_directory}/#{directory_name}"
2
+ @test_directory = "#{@root_test_directory}/#{directory_name}"
3
3
 
4
4
  FileUtils.mkdir(@test_directory) unless File.exists?(@test_directory)
5
5
  end
6
6
 
7
7
  And(/^(?:a|the) file "([^"]*)"$/) do |file_name|
8
- file_path = "#{@default_file_directory}/#{file_name}"
8
+ file_path = "#{@root_test_directory}/#{file_name}"
9
9
 
10
10
  # Some versions of Gherkin require feature content to be present in feature files
11
11
  if file_name =~ /\.feature/
@@ -18,7 +18,7 @@ And(/^(?:a|the) file "([^"]*)"$/) do |file_name|
18
18
  end
19
19
 
20
20
  And(/^the file "([^"]*)":$/) do |file_name, file_text|
21
- file_path = "#{@default_file_directory}/#{file_name}"
21
+ file_path = "#{@root_test_directory}/#{file_name}"
22
22
 
23
23
  File.open(file_path, 'w') { |file| file.write(file_text) }
24
24
  end
@@ -28,7 +28,5 @@ Given(/^the following gherkin:$/) do |text|
28
28
  end
29
29
 
30
30
  Given(/^a feature file with the following gherkin:$/) do |file_text|
31
- @file_path = "#{@default_file_directory}/#{@default_feature_file_name}"
32
-
33
- File.open(@file_path, 'w') { |file| file.write(file_text) }
31
+ @file_path = CukeModeler::FileHelper.create_feature_file(:text => file_text)
34
32
  end
@@ -12,7 +12,7 @@ Then(/^all of them can be output as text appropriate to the model type$/) do |co
12
12
  end
13
13
 
14
14
  Then(/^the following text is provided:$/) do |expected_text|
15
- expected_text.sub!('<path_to>', @default_file_directory)
15
+ expected_text.sub!('<path_to>', @root_test_directory)
16
16
 
17
17
  expect(@output).to eq(expected_text)
18
18
  end
@@ -57,13 +57,13 @@ Then(/^all of them can be created without further context$/) do |code_text|
57
57
  end
58
58
 
59
59
  Then(/^the model returns "([^"]*)"$/) do |value|
60
- value.gsub!('path_to', @default_file_directory) if value.is_a?(String)
60
+ value.gsub!('path_to', @root_test_directory) if value.is_a?(String)
61
61
 
62
62
  expect(@result).to eq(value)
63
63
  end
64
64
 
65
65
  Then(/^the model returns$/) do |value|
66
- value.gsub!('path_to', @default_file_directory) if value.is_a?(String)
66
+ value.gsub!('path_to', @root_test_directory) if value.is_a?(String)
67
67
 
68
68
  expect(@result).to eq(value)
69
69
  end
@@ -10,13 +10,12 @@ this_dir = File.dirname(__FILE__)
10
10
 
11
11
  require "#{this_dir}/../../../lib/cuke_modeler"
12
12
 
13
+ require "#{this_dir}/../../file_helper"
14
+
13
15
 
14
16
  Before do
15
17
  begin
16
- @default_file_directory = "#{this_dir}/../temp_files"
17
- @default_feature_file_name = 'test_feature.feature'
18
-
19
- FileUtils.mkdir(@default_file_directory)
18
+ @root_test_directory = CukeModeler::FileHelper.create_directory
20
19
  rescue => e
21
20
  $stdout.puts 'Problem caught in Before hook!'
22
21
  $stdout.puts "Type: #{e.class}"
@@ -24,14 +23,8 @@ Before do
24
23
  end
25
24
  end
26
25
 
27
- After do
28
- begin
29
- FileUtils.remove_dir(@default_file_directory, true)
30
- rescue => e
31
- $stdout.puts 'Problem caught in After hook!'
32
- $stdout.puts "Type: #{e.class}"
33
- $stdout.puts "Message: #{e.message}"
26
+ at_exit {
27
+ CukeModeler::FileHelper.created_directories.each do |dir_path|
28
+ FileUtils.remove_entry(dir_path, true)
34
29
  end
35
- end
36
-
37
-
30
+ }
@@ -0,0 +1,44 @@
1
+ module CukeModeler
2
+ module FileHelper
3
+
4
+ class << self
5
+
6
+ def create_feature_file(options = {})
7
+ options[:text] ||= 'Feature:'
8
+ options[:name] ||= 'test_file'
9
+
10
+ create_file(:text => options[:text], :name => options[:name], :extension => '.feature', :directory => options[:directory])
11
+ end
12
+
13
+ def create_file(options = {})
14
+ options[:text] ||= ''
15
+ options[:name] ||= 'test_file'
16
+ options[:extension] ||= '.txt'
17
+ options[:directory] ||= create_directory
18
+
19
+ file_path = "#{options[:directory]}/#{options[:name]}#{options[:extension]}"
20
+ File.open(file_path, 'w') { |file| file.write(options[:text]) }
21
+
22
+ file_path
23
+ end
24
+
25
+ def created_directories
26
+ @created_directories ||= []
27
+ end
28
+
29
+ def create_directory(options = {})
30
+ options[:name] ||= 'test_directory'
31
+ options[:directory] ||= Dir.mktmpdir
32
+
33
+ path = "#{options[:directory]}/#{options[:name]}"
34
+
35
+ Dir::mkdir(path)
36
+ created_directories << options[:directory]
37
+
38
+ path
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,20 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => "../../"
4
+ gem "gherkin", "~> 5.0"
5
+
6
+ # cuke_modeler can play with pretty much any version of these but they all play differently with Ruby
7
+
8
+ if RUBY_VERSION =~ /^1\./
9
+
10
+ gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
11
+ gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
12
+ gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
13
+
14
+ elsif RUBY_VERSION =~ /^2\./
15
+
16
+ if RUBY_VERSION =~ /^2\.[23456789]/
17
+ gem 'test-unit'
18
+ end
19
+
20
+ end
@@ -103,39 +103,41 @@ describe 'Background, Integration' do
103
103
  describe 'getting ancestors' do
104
104
 
105
105
  before(:each) do
106
- source = "#{@feature_keyword}: Test feature
106
+ CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'background_test_file', :directory => test_directory)
107
+ end
107
108
 
108
- #{@background_keyword}: Test background
109
- #{@step_keyword} a step"
110
109
 
111
- file_path = "#{@default_file_directory}/background_test_file.feature"
112
- File.open(file_path, 'w') { |file| file.write(source) }
113
- end
110
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
111
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
112
+
113
+ #{@background_keyword}: Test background
114
+ #{@step_keyword} a step"
115
+ }
114
116
 
115
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
116
- let(:background) { directory.feature_files.first.feature.background }
117
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
118
+ let(:background_model) { directory_model.feature_files.first.feature.background }
117
119
 
118
120
 
119
121
  it 'can get its directory' do
120
- ancestor = background.get_ancestor(:directory)
122
+ ancestor = background_model.get_ancestor(:directory)
121
123
 
122
- expect(ancestor).to equal(directory)
124
+ expect(ancestor).to equal(directory_model)
123
125
  end
124
126
 
125
127
  it 'can get its feature file' do
126
- ancestor = background.get_ancestor(:feature_file)
128
+ ancestor = background_model.get_ancestor(:feature_file)
127
129
 
128
- expect(ancestor).to equal(directory.feature_files.first)
130
+ expect(ancestor).to equal(directory_model.feature_files.first)
129
131
  end
130
132
 
131
133
  it 'can get its feature' do
132
- ancestor = background.get_ancestor(:feature)
134
+ ancestor = background_model.get_ancestor(:feature)
133
135
 
134
- expect(ancestor).to equal(directory.feature_files.first.feature)
136
+ expect(ancestor).to equal(directory_model.feature_files.first.feature)
135
137
  end
136
138
 
137
139
  it 'returns nil if it does not have the requested type of ancestor' do
138
- ancestor = background.get_ancestor(:example)
140
+ ancestor = background_model.get_ancestor(:example)
139
141
 
140
142
  expect(ancestor).to be_nil
141
143
  end
@@ -72,73 +72,72 @@ describe 'Cell, Integration' do
72
72
  describe 'getting ancestors' do
73
73
 
74
74
  before(:each) do
75
- source = "#{@feature_keyword}: Test feature
75
+ CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'cell_test_file', :directory => test_directory)
76
+ end
76
77
 
77
- #{@scenario_keyword}: Test test
78
- #{@step_keyword} a step
79
- | a value |"
80
78
 
81
- file_path = "#{@default_file_directory}/cell_test_file.feature"
82
- File.open(file_path, 'w') { |file| file.write(source) }
83
- end
79
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
80
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
81
+
82
+ #{@scenario_keyword}: Test test
83
+ #{@step_keyword} a step
84
+ | a value |"
85
+ }
84
86
 
85
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
86
- let(:cell) { directory.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
87
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
88
+ let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
87
89
 
88
90
 
89
91
  it 'can get its directory' do
90
- ancestor = cell.get_ancestor(:directory)
92
+ ancestor = cell_model.get_ancestor(:directory)
91
93
 
92
- expect(ancestor).to equal(directory)
94
+ expect(ancestor).to equal(directory_model)
93
95
  end
94
96
 
95
97
  it 'can get its feature file' do
96
- ancestor = cell.get_ancestor(:feature_file)
98
+ ancestor = cell_model.get_ancestor(:feature_file)
97
99
 
98
- expect(ancestor).to equal(directory.feature_files.first)
100
+ expect(ancestor).to equal(directory_model.feature_files.first)
99
101
  end
100
102
 
101
103
  it 'can get its feature' do
102
- ancestor = cell.get_ancestor(:feature)
104
+ ancestor = cell_model.get_ancestor(:feature)
103
105
 
104
- expect(ancestor).to equal(directory.feature_files.first.feature)
106
+ expect(ancestor).to equal(directory_model.feature_files.first.feature)
105
107
  end
106
108
 
107
109
  context 'a cell that is part of an outline' do
108
110
 
109
- before(:each) do
110
- source = "#{@feature_keyword}: Test feature
111
-
112
- #{@outline_keyword}: Test outline
113
- #{@step_keyword} a step
114
- #{@example_keyword}:
115
- | param |
116
- | value |"
117
-
118
- file_path = "#{@default_file_directory}/cell_test_file.feature"
119
- File.open(file_path, 'w') { |file| file.write(source) }
120
- end
111
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
112
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
113
+
114
+ #{@outline_keyword}: Test outline
115
+ #{@step_keyword} a step
116
+ #{@example_keyword}:
117
+ | param |
118
+ | value |"
119
+ }
121
120
 
122
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
123
- let(:cell) { directory.feature_files.first.feature.tests.first.examples.first.rows.first.cells.first }
121
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
122
+ let(:cell_model) { directory_model.feature_files.first.feature.tests.first.examples.first.rows.first.cells.first }
124
123
 
125
124
 
126
125
  it 'can get its outline' do
127
- ancestor = cell.get_ancestor(:outline)
126
+ ancestor = cell_model.get_ancestor(:outline)
128
127
 
129
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
128
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
130
129
  end
131
130
 
132
131
  it 'can get its example' do
133
- ancestor = cell.get_ancestor(:example)
132
+ ancestor = cell_model.get_ancestor(:example)
134
133
 
135
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.examples.first)
134
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first)
136
135
  end
137
136
 
138
137
  it 'can get its row' do
139
- ancestor = cell.get_ancestor(:row)
138
+ ancestor = cell_model.get_ancestor(:row)
140
139
 
141
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.examples.first.rows.first)
140
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first.rows.first)
142
141
  end
143
142
 
144
143
  end
@@ -146,93 +145,84 @@ describe 'Cell, Integration' do
146
145
 
147
146
  context 'a cell that is part of a scenario' do
148
147
 
149
- before(:each) do
150
- source = "#{@feature_keyword}: Test feature
148
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
149
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
151
150
 
152
- #{@scenario_keyword}: Test test
153
- #{@step_keyword} a step:
154
- | a | table |"
151
+ #{@scenario_keyword}: Test test
152
+ #{@step_keyword} a step:
153
+ | a | table |"
154
+ }
155
155
 
156
- file_path = "#{@default_file_directory}/cell_test_file.feature"
157
- File.open(file_path, 'w') { |file| file.write(source) }
158
- end
159
-
160
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
161
- let(:cell) { directory.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
156
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
157
+ let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
162
158
 
163
159
 
164
160
  it 'can get its scenario' do
165
- ancestor = cell.get_ancestor(:scenario)
161
+ ancestor = cell_model.get_ancestor(:scenario)
166
162
 
167
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first)
163
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
168
164
  end
169
165
 
170
166
  end
171
167
 
172
168
  context 'a cell that is part of a background' do
173
169
 
174
- before(:each) do
175
- source = "#{@feature_keyword}: Test feature
176
-
177
- #{@background_keyword}: Test background
178
- #{@step_keyword} a step:
179
- | a | table |"
170
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
171
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
180
172
 
181
- file_path = "#{@default_file_directory}/cell_test_file.feature"
182
- File.open(file_path, 'w') { |file| file.write(source) }
183
- end
173
+ #{@background_keyword}: Test background
174
+ #{@step_keyword} a step:
175
+ | a | table |"
176
+ }
184
177
 
185
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
186
- let(:cell) { directory.feature_files.first.feature.background.steps.first.block.rows.first.cells.first }
178
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
179
+ let(:cell_model) { directory_model.feature_files.first.feature.background.steps.first.block.rows.first.cells.first }
187
180
 
188
181
 
189
182
  it 'can get its background' do
190
- ancestor = cell.get_ancestor(:background)
183
+ ancestor = cell_model.get_ancestor(:background)
191
184
 
192
- expect(ancestor).to equal(directory.feature_files.first.feature.background)
185
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
193
186
  end
194
187
 
195
188
  end
196
189
 
197
190
  context 'a cell that is part of a step' do
198
191
 
199
- before(:each) do
200
- source = "#{@feature_keyword}: Test feature
192
+ let(:test_directory) { CukeModeler::FileHelper.create_directory }
193
+ let(:source_gherkin) { "#{@feature_keyword}: Test feature
201
194
 
202
- #{@scenario_keyword}: Test test
203
- #{@step_keyword} a step:
204
- | a | table |"
205
-
206
- file_path = "#{@default_file_directory}/cell_test_file.feature"
207
- File.open(file_path, 'w') { |file| file.write(source) }
208
- end
195
+ #{@scenario_keyword}: Test test
196
+ #{@step_keyword} a step:
197
+ | a | table |"
198
+ }
209
199
 
210
- let(:directory) { CukeModeler::Directory.new(@default_file_directory) }
211
- let(:cell) { directory.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
200
+ let(:directory_model) { CukeModeler::Directory.new(test_directory) }
201
+ let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
212
202
 
213
203
 
214
204
  it 'can get its step' do
215
- ancestor = cell.get_ancestor(:step)
205
+ ancestor = cell_model.get_ancestor(:step)
216
206
 
217
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.steps.first)
207
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
218
208
  end
219
209
 
220
210
  it 'can get its table' do
221
- ancestor = cell.get_ancestor(:table)
211
+ ancestor = cell_model.get_ancestor(:table)
222
212
 
223
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.steps.first.block)
213
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block)
224
214
  end
225
215
 
226
216
  it 'can get its row' do
227
- ancestor = cell.get_ancestor(:row)
217
+ ancestor = cell_model.get_ancestor(:row)
228
218
 
229
- expect(ancestor).to equal(directory.feature_files.first.feature.tests.first.steps.first.block.rows.first)
219
+ expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first)
230
220
  end
231
221
 
232
222
  end
233
223
 
234
224
  it 'returns nil if it does not have the requested type of ancestor' do
235
- ancestor = cell.get_ancestor(:example)
225
+ ancestor = cell_model.get_ancestor(:example)
236
226
 
237
227
  expect(ancestor).to be_nil
238
228
  end