cuke_modeler 1.3.0 → 2.1.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 (90) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +60 -17
  3. data/CHANGELOG.md +312 -0
  4. data/Gemfile +19 -3
  5. data/LICENSE.txt +1 -1
  6. data/README.md +17 -7
  7. data/Rakefile +45 -28
  8. data/appveyor.yml +57 -17
  9. data/cuke_modeler.gemspec +6 -3
  10. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +1 -0
  11. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +1 -0
  12. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +2 -1
  13. data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +12 -0
  14. data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +310 -0
  15. data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +307 -0
  16. data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +12 -0
  17. data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +12 -0
  18. data/lib/cuke_modeler/containing.rb +16 -0
  19. data/lib/cuke_modeler/described.rb +1 -0
  20. data/lib/cuke_modeler/models/step.rb +31 -2
  21. data/lib/cuke_modeler/named.rb +1 -0
  22. data/lib/cuke_modeler/nested.rb +1 -0
  23. data/lib/cuke_modeler/parsed.rb +1 -0
  24. data/lib/cuke_modeler/parsing.rb +116 -68
  25. data/lib/cuke_modeler/sourceable.rb +1 -0
  26. data/lib/cuke_modeler/stepped.rb +1 -0
  27. data/lib/cuke_modeler/taggable.rb +1 -0
  28. data/lib/cuke_modeler/version.rb +1 -1
  29. data/testing/cucumber/features/analysis/step_comparison.feature +25 -0
  30. data/testing/cucumber/features/analysis/test_comparison.feature +1 -1
  31. data/testing/cucumber/step_definitions/feature_file_steps.rb +1 -1
  32. data/testing/cucumber/step_definitions/modeling_steps.rb +7 -2
  33. data/testing/cucumber/step_definitions/verification_steps.rb +11 -2
  34. data/testing/file_helper.rb +3 -0
  35. data/testing/gemfiles/gherkin2.gemfile +8 -0
  36. data/testing/gemfiles/gherkin3.gemfile +6 -0
  37. data/testing/gemfiles/gherkin4.gemfile +7 -0
  38. data/testing/gemfiles/gherkin5.gemfile +7 -0
  39. data/testing/gemfiles/gherkin6.gemfile +10 -0
  40. data/testing/gemfiles/gherkin7.gemfile +9 -0
  41. data/testing/gemfiles/gherkin8.gemfile +9 -0
  42. data/testing/gemfiles/gherkin9.gemfile +9 -0
  43. data/testing/helper_methods.rb +23 -0
  44. data/testing/rspec/spec/integration/{gherkin_2_adapter_spec.rb → adapters/gherkin_2_adapter_spec.rb} +13 -13
  45. data/testing/rspec/spec/integration/{gherkin_3_adapter_spec.rb → adapters/gherkin_3_adapter_spec.rb} +13 -13
  46. data/testing/rspec/spec/integration/{gherkin_4_adapter_spec.rb → adapters/gherkin_4_adapter_spec.rb} +13 -13
  47. data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +165 -0
  48. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +159 -0
  49. data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +162 -0
  50. data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +162 -0
  51. data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +162 -0
  52. data/testing/rspec/spec/integration/{background_integration_spec.rb → models/background_integration_spec.rb} +90 -86
  53. data/testing/rspec/spec/integration/{cell_integration_spec.rb → models/cell_integration_spec.rb} +49 -38
  54. data/testing/rspec/spec/integration/{comment_integration_spec.rb → models/comment_integration_spec.rb} +31 -20
  55. data/testing/rspec/spec/integration/{directory_integration_spec.rb → models/directory_integration_spec.rb} +3 -3
  56. data/testing/rspec/spec/integration/{doc_string_integration_spec.rb → models/doc_string_integration_spec.rb} +39 -35
  57. data/testing/rspec/spec/integration/{example_integration_spec.rb → models/example_integration_spec.rb} +109 -83
  58. data/testing/rspec/spec/integration/{feature_file_integration_spec.rb → models/feature_file_integration_spec.rb} +52 -38
  59. data/testing/rspec/spec/integration/{feature_integration_spec.rb → models/feature_integration_spec.rb} +125 -112
  60. data/testing/rspec/spec/integration/{model_integration_spec.rb → models/model_integration_spec.rb} +1 -1
  61. data/testing/rspec/spec/integration/{outline_integration_spec.rb → models/outline_integration_spec.rb} +138 -129
  62. data/testing/rspec/spec/integration/{row_integration_spec.rb → models/row_integration_spec.rb} +55 -35
  63. data/testing/rspec/spec/integration/{scenario_integration_spec.rb → models/scenario_integration_spec.rb} +92 -88
  64. data/testing/rspec/spec/integration/models/step_integration_spec.rb +573 -0
  65. data/testing/rspec/spec/integration/{table_integration_spec.rb → models/table_integration_spec.rb} +38 -34
  66. data/testing/rspec/spec/integration/{tag_integration_spec.rb → models/tag_integration_spec.rb} +56 -36
  67. data/testing/rspec/spec/integration/parsing_integration_spec.rb +45 -7
  68. data/testing/rspec/spec/spec_helper.rb +79 -43
  69. data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +25 -0
  70. data/testing/rspec/spec/unit/{background_unit_spec.rb → models/background_unit_spec.rb} +1 -1
  71. data/testing/rspec/spec/unit/{cell_unit_spec.rb → models/cell_unit_spec.rb} +1 -1
  72. data/testing/rspec/spec/unit/{comment_unit_spec.rb → models/comment_unit_spec.rb} +1 -1
  73. data/testing/rspec/spec/unit/{directory_unit_spec.rb → models/directory_unit_spec.rb} +1 -1
  74. data/testing/rspec/spec/unit/{doc_string_unit_spec.rb → models/doc_string_unit_spec.rb} +1 -1
  75. data/testing/rspec/spec/unit/{example_unit_spec.rb → models/example_unit_spec.rb} +1 -1
  76. data/testing/rspec/spec/unit/{feature_file_unit_spec.rb → models/feature_file_unit_spec.rb} +1 -1
  77. data/testing/rspec/spec/unit/{feature_unit_spec.rb → models/feature_unit_spec.rb} +1 -1
  78. data/testing/rspec/spec/unit/{model_unit_spec.rb → models/model_unit_spec.rb} +1 -1
  79. data/testing/rspec/spec/unit/{outline_unit_spec.rb → models/outline_unit_spec.rb} +1 -1
  80. data/testing/rspec/spec/unit/{row_unit_spec.rb → models/row_unit_spec.rb} +1 -1
  81. data/testing/rspec/spec/unit/{scenario_unit_spec.rb → models/scenario_unit_spec.rb} +1 -1
  82. data/testing/rspec/spec/unit/{step_unit_spec.rb → models/step_unit_spec.rb} +2 -2
  83. data/testing/rspec/spec/unit/{table_unit_spec.rb → models/table_unit_spec.rb} +1 -1
  84. data/testing/rspec/spec/unit/{tag_unit_spec.rb → models/tag_unit_spec.rb} +1 -1
  85. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +102 -0
  86. data/todo.txt +5 -2
  87. metadata +80 -47
  88. data/History.md +0 -186
  89. data/testing/cucumber/support/transforms.rb +0 -3
  90. data/testing/rspec/spec/integration/step_integration_spec.rb +0 -459
@@ -0,0 +1,162 @@
1
+ require "#{File.dirname(__FILE__)}/../../spec_helper"
2
+
3
+
4
+ describe 'Gherkin8Adapter, Integration', :if => gherkin?(8) do
5
+
6
+ let(:clazz) { CukeModeler::Gherkin8Adapter }
7
+ let(:adapter) { clazz.new }
8
+ let(:source_text) { "# feature comment
9
+ @tag1 @tag2 @tag3
10
+ #{FEATURE_KEYWORD}: A feature with everything it could have
11
+
12
+ Including a description
13
+ and then some.
14
+
15
+ # background comment
16
+ #{BACKGROUND_KEYWORD}:
17
+
18
+ Background
19
+ description
20
+
21
+ #{STEP_KEYWORD} a step
22
+ # table comment
23
+ | value1 |
24
+ # table row comment
25
+ | value2 |
26
+ #{STEP_KEYWORD} another step
27
+
28
+ # scenario comment
29
+ @scenario_tag
30
+ #{SCENARIO_KEYWORD}:
31
+
32
+ Scenario
33
+ description
34
+
35
+ #{STEP_KEYWORD} a step
36
+ #{STEP_KEYWORD} another step
37
+ \"\"\"
38
+ some text
39
+ \"\"\"
40
+
41
+ # outline comment
42
+ @outline_tag
43
+ #{OUTLINE_KEYWORD}:
44
+
45
+ Outline
46
+ description
47
+
48
+ # step comment
49
+ #{STEP_KEYWORD} a step
50
+ # table comment
51
+ | value2 |
52
+ # step comment
53
+ #{STEP_KEYWORD} another step
54
+ # doc string comment
55
+ \"\"\"
56
+ some text
57
+ \"\"\"
58
+
59
+ # example comment
60
+ @example_tag
61
+ #{EXAMPLE_KEYWORD}:
62
+
63
+ Example
64
+ description
65
+
66
+ # row comment
67
+ | param |
68
+ | value |
69
+ # final comment" }
70
+ let(:feature_file_model) do
71
+ test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'adapter_test_file')
72
+
73
+ CukeModeler::FeatureFile.new(test_file_path)
74
+ end
75
+ let(:feature_model) { feature_file_model.feature }
76
+
77
+
78
+ it "does not store parsing data for a feature file's children" do
79
+ model = feature_file_model
80
+
81
+ expect(model.parsing_data[:comments]).to be_nil
82
+ expect(model.parsing_data[:feature]).to be_nil
83
+ end
84
+
85
+ it "does not store parsing data for a feature's children" do
86
+ model = feature_model
87
+
88
+ expect(model.parsing_data[:tags]).to be_nil
89
+ expect(model.parsing_data[:children]).to be_nil
90
+ end
91
+
92
+ it "does not store parsing data for a background's children" do
93
+ model = feature_model.background
94
+
95
+ expect(model.parsing_data[:background][:steps]).to be_nil
96
+ end
97
+
98
+ it "does not store parsing data for a scenario's children" do
99
+ model = feature_model.scenarios.first
100
+
101
+ expect(model.parsing_data[:scenario][:tags]).to be_nil
102
+ expect(model.parsing_data[:scenario][:steps]).to be_nil
103
+ end
104
+
105
+ it "does not store parsing data for an outline's children" do
106
+ model = feature_model.outlines.first
107
+
108
+ expect(model.parsing_data[:scenario][:tags]).to be_nil
109
+ expect(model.parsing_data[:scenario][:steps]).to be_nil
110
+ expect(model.parsing_data[:scenario][:examples]).to be_nil
111
+ end
112
+
113
+ it "does not store parsing data for an example's children" do
114
+ model = feature_model.outlines.first.examples.first
115
+
116
+ expect(model.parsing_data[:tags]).to be_nil
117
+ expect(model.parsing_data[:table_header]).to be_nil
118
+ expect(model.parsing_data[:table_body]).to be_nil
119
+ end
120
+
121
+ it "does not store parsing data for an example row's children" do
122
+ model = feature_model.outlines.first.examples.first.rows.first
123
+
124
+ expect(model.parsing_data[:cells]).to be_nil
125
+ end
126
+
127
+ it "does not store parsing data for a step's children, table" do
128
+ model = feature_model.outlines.first.steps.first
129
+
130
+ expect(model.parsing_data[:data_table]).to be_nil
131
+ end
132
+
133
+ it "does not store parsing data for a step's children, doc string" do
134
+ model = feature_model.outlines.first.steps.last
135
+
136
+ expect(model.parsing_data[:doc_string]).to be_nil
137
+ end
138
+
139
+ it "does not store parsing data for a table's children" do
140
+ model = feature_model.outlines.first.steps.first.block
141
+
142
+ expect(model.parsing_data[:rows]).to be_nil
143
+ end
144
+
145
+ it "does not store parsing data for a table row's children" do
146
+ model = feature_model.outlines.first.steps.first.block.rows.first
147
+
148
+ expect(model.parsing_data[:cells]).to be_nil
149
+ end
150
+
151
+
152
+ describe 'stuff that is in no way part of the public API and entirely subject to change' do
153
+
154
+ it 'provides a useful explosion message if it encounters an entirely new type of test' do
155
+ partial_feature_ast = { :type => :Feature, :location => { :line => 1, :column => 1 }, :children => [{ :some_unknown_type => {} }] }
156
+
157
+ expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
158
+ end
159
+
160
+ end
161
+
162
+ end
@@ -0,0 +1,162 @@
1
+ require "#{File.dirname(__FILE__)}/../../spec_helper"
2
+
3
+
4
+ describe 'Gherkin9Adapter, Integration', :if => gherkin?(9) do
5
+
6
+ let(:clazz) { CukeModeler::Gherkin9Adapter }
7
+ let(:adapter) { clazz.new }
8
+ let(:source_text) { "# feature comment
9
+ @tag1 @tag2 @tag3
10
+ #{FEATURE_KEYWORD}: A feature with everything it could have
11
+
12
+ Including a description
13
+ and then some.
14
+
15
+ # background comment
16
+ #{BACKGROUND_KEYWORD}:
17
+
18
+ Background
19
+ description
20
+
21
+ #{STEP_KEYWORD} a step
22
+ # table comment
23
+ | value1 |
24
+ # table row comment
25
+ | value2 |
26
+ #{STEP_KEYWORD} another step
27
+
28
+ # scenario comment
29
+ @scenario_tag
30
+ #{SCENARIO_KEYWORD}:
31
+
32
+ Scenario
33
+ description
34
+
35
+ #{STEP_KEYWORD} a step
36
+ #{STEP_KEYWORD} another step
37
+ \"\"\"
38
+ some text
39
+ \"\"\"
40
+
41
+ # outline comment
42
+ @outline_tag
43
+ #{OUTLINE_KEYWORD}:
44
+
45
+ Outline
46
+ description
47
+
48
+ # step comment
49
+ #{STEP_KEYWORD} a step
50
+ # table comment
51
+ | value2 |
52
+ # step comment
53
+ #{STEP_KEYWORD} another step
54
+ # doc string comment
55
+ \"\"\"
56
+ some text
57
+ \"\"\"
58
+
59
+ # example comment
60
+ @example_tag
61
+ #{EXAMPLE_KEYWORD}:
62
+
63
+ Example
64
+ description
65
+
66
+ # row comment
67
+ | param |
68
+ | value |
69
+ # final comment" }
70
+ let(:feature_file_model) do
71
+ test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'adapter_test_file')
72
+
73
+ CukeModeler::FeatureFile.new(test_file_path)
74
+ end
75
+ let(:feature_model) { feature_file_model.feature }
76
+
77
+
78
+ it "does not store parsing data for a feature file's children" do
79
+ model = feature_file_model
80
+
81
+ expect(model.parsing_data[:comments]).to be_nil
82
+ expect(model.parsing_data[:feature]).to be_nil
83
+ end
84
+
85
+ it "does not store parsing data for a feature's children" do
86
+ model = feature_model
87
+
88
+ expect(model.parsing_data[:tags]).to be_nil
89
+ expect(model.parsing_data[:children]).to be_nil
90
+ end
91
+
92
+ it "does not store parsing data for a background's children" do
93
+ model = feature_model.background
94
+
95
+ expect(model.parsing_data[:background][:steps]).to be_nil
96
+ end
97
+
98
+ it "does not store parsing data for a scenario's children" do
99
+ model = feature_model.scenarios.first
100
+
101
+ expect(model.parsing_data[:scenario][:tags]).to be_nil
102
+ expect(model.parsing_data[:scenario][:steps]).to be_nil
103
+ end
104
+
105
+ it "does not store parsing data for an outline's children" do
106
+ model = feature_model.outlines.first
107
+
108
+ expect(model.parsing_data[:scenario][:tags]).to be_nil
109
+ expect(model.parsing_data[:scenario][:steps]).to be_nil
110
+ expect(model.parsing_data[:scenario][:examples]).to be_nil
111
+ end
112
+
113
+ it "does not store parsing data for an example's children" do
114
+ model = feature_model.outlines.first.examples.first
115
+
116
+ expect(model.parsing_data[:tags]).to be_nil
117
+ expect(model.parsing_data[:table_header]).to be_nil
118
+ expect(model.parsing_data[:table_body]).to be_nil
119
+ end
120
+
121
+ it "does not store parsing data for an example row's children" do
122
+ model = feature_model.outlines.first.examples.first.rows.first
123
+
124
+ expect(model.parsing_data[:cells]).to be_nil
125
+ end
126
+
127
+ it "does not store parsing data for a step's children, table" do
128
+ model = feature_model.outlines.first.steps.first
129
+
130
+ expect(model.parsing_data[:data_table]).to be_nil
131
+ end
132
+
133
+ it "does not store parsing data for a step's children, doc string" do
134
+ model = feature_model.outlines.first.steps.last
135
+
136
+ expect(model.parsing_data[:doc_string]).to be_nil
137
+ end
138
+
139
+ it "does not store parsing data for a table's children" do
140
+ model = feature_model.outlines.first.steps.first.block
141
+
142
+ expect(model.parsing_data[:rows]).to be_nil
143
+ end
144
+
145
+ it "does not store parsing data for a table row's children" do
146
+ model = feature_model.outlines.first.steps.first.block.rows.first
147
+
148
+ expect(model.parsing_data[:cells]).to be_nil
149
+ end
150
+
151
+
152
+ describe 'stuff that is in no way part of the public API and entirely subject to change' do
153
+
154
+ it 'provides a useful explosion message if it encounters an entirely new type of test' do
155
+ partial_feature_ast = { :type => :Feature, :location => { :line => 1, :column => 1 }, :children => [{ :some_unknown_type => {} }] }
156
+
157
+ expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
158
+ end
159
+
160
+ end
161
+
162
+ end
@@ -1,4 +1,4 @@
1
- require "#{File.dirname(__FILE__)}/../spec_helper"
1
+ require "#{File.dirname(__FILE__)}/../../spec_helper"
2
2
 
3
3
 
4
4
  describe 'Background, Integration' do
@@ -15,7 +15,7 @@ describe 'Background, Integration' do
15
15
  describe 'unique behavior' do
16
16
 
17
17
  it 'can be instantiated with the minimum viable Gherkin' do
18
- source = "#{@background_keyword}:"
18
+ source = "#{BACKGROUND_KEYWORD}:"
19
19
 
20
20
  expect { clazz.new(source) }.to_not raise_error
21
21
  end
@@ -37,39 +37,43 @@ describe 'Background, Integration' do
37
37
  end
38
38
  end
39
39
 
40
- it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
41
- background = clazz.new("#{@background_keyword}: test background\ndescription\n#{@step_keyword} a step")
42
- data = background.parsing_data
40
+ describe 'parsing data' do
43
41
 
44
- expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
45
- expect(data[:type]).to eq(:Background)
46
- end
42
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
43
+ background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
44
+ data = background.parsing_data
47
45
 
48
- it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
49
- background = clazz.new("#{@background_keyword}: test background\ndescription\n#{@step_keyword} a step")
50
- data = background.parsing_data
46
+ expect(data.keys).to match_array([:background, :rule, :scenario])
47
+ expect(data[:background][:name]).to eq('test background')
48
+ end
51
49
 
52
- expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
53
- expect(data[:type]).to eq(:Background)
54
- end
50
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(3, 4, 5) do
51
+ background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
52
+ data = background.parsing_data
55
53
 
56
- it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
57
- background = clazz.new("#{@background_keyword}: test background\ndescription\n#{@step_keyword} a step")
58
- data = background.parsing_data
54
+ expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
55
+ expect(data[:type]).to eq(:Background)
56
+ end
57
+
58
+ it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
59
+ background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
60
+ data = background.parsing_data
61
+
62
+ expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'steps', 'type'])
63
+ expect(data['keyword']).to eq('Background')
64
+ end
59
65
 
60
- expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'steps', 'type'])
61
- expect(data['keyword']).to eq('Background')
62
66
  end
63
67
 
64
68
  it 'provides a descriptive filename when being parsed from stand alone text' do
65
- source = "bad background text \n #{@background_keyword}:\n #{@step_keyword} a step\n @foo "
69
+ source = "bad background text \n #{BACKGROUND_KEYWORD}:\n #{STEP_KEYWORD} a step\n @foo "
66
70
 
67
71
  expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_background\.feature'/)
68
72
  end
69
73
 
70
74
  it 'properly sets its child models' do
71
- source = "#{@background_keyword}: Test background
72
- #{@step_keyword} a step"
75
+ source = "#{BACKGROUND_KEYWORD}: Test background
76
+ #{STEP_KEYWORD} a step"
73
77
 
74
78
  background = clazz.new(source)
75
79
  step = background.steps.first
@@ -78,7 +82,7 @@ describe 'Background, Integration' do
78
82
  end
79
83
 
80
84
  it 'trims whitespace from its source description' do
81
- source = ["#{@background_keyword}:",
85
+ source = ["#{BACKGROUND_KEYWORD}:",
82
86
  ' ',
83
87
  ' description line 1',
84
88
  '',
@@ -87,7 +91,7 @@ describe 'Background, Integration' do
87
91
  '',
88
92
  '',
89
93
  '',
90
- " #{@step_keyword} a step"]
94
+ " #{STEP_KEYWORD} a step"]
91
95
  source = source.join("\n")
92
96
 
93
97
  background = clazz.new(source)
@@ -108,10 +112,10 @@ describe 'Background, Integration' do
108
112
 
109
113
 
110
114
  let(:test_directory) { CukeModeler::FileHelper.create_directory }
111
- let(:source_gherkin) { "#{@feature_keyword}: Test feature
115
+ let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
112
116
 
113
- #{@background_keyword}: Test background
114
- #{@step_keyword} a step"
117
+ #{BACKGROUND_KEYWORD}: Test background
118
+ #{STEP_KEYWORD} a step"
115
119
  }
116
120
 
117
121
  let(:directory_model) { CukeModeler::Directory.new(test_directory) }
@@ -149,19 +153,19 @@ describe 'Background, Integration' do
149
153
 
150
154
  context 'from source text' do
151
155
 
152
- let(:source_text) { "#{@background_keyword}:" }
156
+ let(:source_text) { "#{BACKGROUND_KEYWORD}:" }
153
157
  let(:background) { clazz.new(source_text) }
154
158
 
155
159
 
156
160
  it "models the background's keyword" do
157
- expect(background.keyword).to eq("#{@background_keyword}")
161
+ expect(background.keyword).to eq("#{BACKGROUND_KEYWORD}")
158
162
  end
159
163
 
160
164
  it "models the background's source line" do
161
- source_text = "#{@feature_keyword}:
165
+ source_text = "#{FEATURE_KEYWORD}:
162
166
 
163
- #{@background_keyword}: foo
164
- #{@step_keyword} step"
167
+ #{BACKGROUND_KEYWORD}: foo
168
+ #{STEP_KEYWORD} step"
165
169
  background = CukeModeler::Feature.new(source_text).background
166
170
 
167
171
  expect(background.source_line).to eq(3)
@@ -169,15 +173,15 @@ describe 'Background, Integration' do
169
173
 
170
174
  context 'a filled background' do
171
175
 
172
- let(:source_text) { "#{@background_keyword}: Background name
176
+ let(:source_text) { "#{BACKGROUND_KEYWORD}: Background name
173
177
 
174
178
  Background description.
175
179
 
176
180
  Some more.
177
181
  Even more.
178
182
 
179
- #{@step_keyword} a step
180
- #{@step_keyword} another step" }
183
+ #{STEP_KEYWORD} a step
184
+ #{STEP_KEYWORD} another step" }
181
185
  let(:background) { clazz.new(source_text) }
182
186
 
183
187
 
@@ -204,7 +208,7 @@ describe 'Background, Integration' do
204
208
 
205
209
  context 'an empty background' do
206
210
 
207
- let(:source_text) { "#{@background_keyword}:" }
211
+ let(:source_text) { "#{BACKGROUND_KEYWORD}:" }
208
212
  let(:background) { clazz.new(source_text) }
209
213
 
210
214
 
@@ -230,19 +234,19 @@ describe 'Background, Integration' do
230
234
  describe 'comparison' do
231
235
 
232
236
  it 'is equal to a background with the same steps' do
233
- source = "#{@background_keyword}:
234
- #{@step_keyword} step 1
235
- #{@step_keyword} step 2"
237
+ source = "#{BACKGROUND_KEYWORD}:
238
+ #{STEP_KEYWORD} step 1
239
+ #{STEP_KEYWORD} step 2"
236
240
  background_1 = clazz.new(source)
237
241
 
238
- source = "#{@background_keyword}:
239
- #{@step_keyword} step 1
240
- #{@step_keyword} step 2"
242
+ source = "#{BACKGROUND_KEYWORD}:
243
+ #{STEP_KEYWORD} step 1
244
+ #{STEP_KEYWORD} step 2"
241
245
  background_2 = clazz.new(source)
242
246
 
243
- source = "#{@background_keyword}:
244
- #{@step_keyword} step 2
245
- #{@step_keyword} step 1"
247
+ source = "#{BACKGROUND_KEYWORD}:
248
+ #{STEP_KEYWORD} step 2
249
+ #{STEP_KEYWORD} step 1"
246
250
  background_3 = clazz.new(source)
247
251
 
248
252
 
@@ -251,19 +255,19 @@ describe 'Background, Integration' do
251
255
  end
252
256
 
253
257
  it 'is equal to a scenario with the same steps' do
254
- source = "#{@background_keyword}:
255
- #{@step_keyword} step 1
256
- #{@step_keyword} step 2"
258
+ source = "#{BACKGROUND_KEYWORD}:
259
+ #{STEP_KEYWORD} step 1
260
+ #{STEP_KEYWORD} step 2"
257
261
  background = clazz.new(source)
258
262
 
259
- source = "#{@scenario_keyword}:
260
- #{@step_keyword} step 1
261
- #{@step_keyword} step 2"
263
+ source = "#{SCENARIO_KEYWORD}:
264
+ #{STEP_KEYWORD} step 1
265
+ #{STEP_KEYWORD} step 2"
262
266
  scenario_1 = CukeModeler::Scenario.new(source)
263
267
 
264
- source = "#{@scenario_keyword}:
265
- #{@step_keyword} step 2
266
- #{@step_keyword} step 1"
268
+ source = "#{SCENARIO_KEYWORD}:
269
+ #{STEP_KEYWORD} step 2
270
+ #{STEP_KEYWORD} step 1"
267
271
  scenario_2 = CukeModeler::Scenario.new(source)
268
272
 
269
273
 
@@ -272,23 +276,23 @@ describe 'Background, Integration' do
272
276
  end
273
277
 
274
278
  it 'is equal to an outline with the same steps' do
275
- source = "#{@background_keyword}:
276
- #{@step_keyword} step 1
277
- #{@step_keyword} step 2"
279
+ source = "#{BACKGROUND_KEYWORD}:
280
+ #{STEP_KEYWORD} step 1
281
+ #{STEP_KEYWORD} step 2"
278
282
  background = clazz.new(source)
279
283
 
280
- source = "#{@outline_keyword}:
281
- #{@step_keyword} step 1
282
- #{@step_keyword} step 2
283
- #{@example_keyword}:
284
+ source = "#{OUTLINE_KEYWORD}:
285
+ #{STEP_KEYWORD} step 1
286
+ #{STEP_KEYWORD} step 2
287
+ #{EXAMPLE_KEYWORD}:
284
288
  | param |
285
289
  | value |"
286
290
  outline_1 = CukeModeler::Outline.new(source)
287
291
 
288
- source = "#{@outline_keyword}:
289
- #{@step_keyword} step 2
290
- #{@step_keyword} step 1
291
- #{@example_keyword}:
292
+ source = "#{OUTLINE_KEYWORD}:
293
+ #{STEP_KEYWORD} step 2
294
+ #{STEP_KEYWORD} step 1
295
+ #{EXAMPLE_KEYWORD}:
292
296
  | param |
293
297
  | value |"
294
298
  outline_2 = CukeModeler::Outline.new(source)
@@ -304,14 +308,14 @@ describe 'Background, Integration' do
304
308
  describe 'background output' do
305
309
 
306
310
  it 'can be remade from its own output' do
307
- source = "#{@background_keyword}: A background with everything it could have
311
+ source = "#{BACKGROUND_KEYWORD}: A background with everything it could have
308
312
 
309
313
  Including a description
310
314
  and then some.
311
315
 
312
- #{@step_keyword} a step
316
+ #{STEP_KEYWORD} a step
313
317
  | value |
314
- #{@step_keyword} another step
318
+ #{STEP_KEYWORD} another step
315
319
  \"\"\"
316
320
  some string
317
321
  \"\"\""
@@ -327,27 +331,27 @@ describe 'Background, Integration' do
327
331
  context 'from source text' do
328
332
 
329
333
  it 'can output an empty background' do
330
- source = ["#{@background_keyword}:"]
334
+ source = ["#{BACKGROUND_KEYWORD}:"]
331
335
  source = source.join("\n")
332
336
  background = clazz.new(source)
333
337
 
334
338
  background_output = background.to_s.split("\n", -1)
335
339
 
336
- expect(background_output).to eq(["#{@background_keyword}:"])
340
+ expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:"])
337
341
  end
338
342
 
339
343
  it 'can output a background that has a name' do
340
- source = ["#{@background_keyword}: test background"]
344
+ source = ["#{BACKGROUND_KEYWORD}: test background"]
341
345
  source = source.join("\n")
342
346
  background = clazz.new(source)
343
347
 
344
348
  background_output = background.to_s.split("\n", -1)
345
349
 
346
- expect(background_output).to eq(["#{@background_keyword}: test background"])
350
+ expect(background_output).to eq(["#{BACKGROUND_KEYWORD}: test background"])
347
351
  end
348
352
 
349
353
  it 'can output a background that has a description' do
350
- source = ["#{@background_keyword}:",
354
+ source = ["#{BACKGROUND_KEYWORD}:",
351
355
  'Some description.',
352
356
  'Some more description.']
353
357
  source = source.join("\n")
@@ -355,17 +359,17 @@ describe 'Background, Integration' do
355
359
 
356
360
  background_output = background.to_s.split("\n", -1)
357
361
 
358
- expect(background_output).to eq(["#{@background_keyword}:",
362
+ expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:",
359
363
  '',
360
364
  'Some description.',
361
365
  'Some more description.'])
362
366
  end
363
367
 
364
368
  it 'can output a background that has steps' do
365
- source = ["#{@background_keyword}:",
366
- "#{@step_keyword} a step",
369
+ source = ["#{BACKGROUND_KEYWORD}:",
370
+ "#{STEP_KEYWORD} a step",
367
371
  '|value|',
368
- "#{@step_keyword} another step",
372
+ "#{STEP_KEYWORD} another step",
369
373
  '"""',
370
374
  'some string',
371
375
  '"""']
@@ -374,22 +378,22 @@ describe 'Background, Integration' do
374
378
 
375
379
  background_output = background.to_s.split("\n", -1)
376
380
 
377
- expect(background_output).to eq(["#{@background_keyword}:",
378
- " #{@step_keyword} a step",
381
+ expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:",
382
+ " #{STEP_KEYWORD} a step",
379
383
  ' | value |',
380
- " #{@step_keyword} another step",
384
+ " #{STEP_KEYWORD} another step",
381
385
  ' """',
382
386
  ' some string',
383
387
  ' """'])
384
388
  end
385
389
 
386
390
  it 'can output a background that has everything' do
387
- source = ["#{@background_keyword}: A background with everything it could have",
391
+ source = ["#{BACKGROUND_KEYWORD}: A background with everything it could have",
388
392
  'Including a description',
389
393
  'and then some.',
390
- "#{@step_keyword} a step",
394
+ "#{STEP_KEYWORD} a step",
391
395
  '|value|',
392
- "#{@step_keyword} another step",
396
+ "#{STEP_KEYWORD} another step",
393
397
  '"""',
394
398
  'some string',
395
399
  '"""']
@@ -398,14 +402,14 @@ describe 'Background, Integration' do
398
402
 
399
403
  background_output = background.to_s.split("\n", -1)
400
404
 
401
- expect(background_output).to eq(["#{@background_keyword}: A background with everything it could have",
405
+ expect(background_output).to eq(["#{BACKGROUND_KEYWORD}: A background with everything it could have",
402
406
  '',
403
407
  'Including a description',
404
408
  'and then some.',
405
409
  '',
406
- " #{@step_keyword} a step",
410
+ " #{STEP_KEYWORD} a step",
407
411
  ' | value |',
408
- " #{@step_keyword} another step",
412
+ " #{STEP_KEYWORD} another step",
409
413
  ' """',
410
414
  ' some string',
411
415
  ' """'])