cuke_linter 0.13.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +4 -4
  4. data/cuke_linter.gemspec +3 -3
  5. data/lib/cuke_linter.rb +5 -3
  6. data/lib/cuke_linter/version.rb +1 -1
  7. metadata +2 -86
  8. data/.gitignore +0 -19
  9. data/.simplecov +0 -8
  10. data/.travis.yml +0 -33
  11. data/CONTRIBUTING.md +0 -26
  12. data/Gemfile +0 -6
  13. data/Rakefile +0 -63
  14. data/appveyor.yml +0 -43
  15. data/bin/console +0 -14
  16. data/bin/setup +0 -8
  17. data/environments/common_env.rb +0 -12
  18. data/environments/cucumber_env.rb +0 -22
  19. data/environments/rspec_env.rb +0 -50
  20. data/testing/cucumber/step_definitions/action_steps.rb +0 -84
  21. data/testing/cucumber/step_definitions/setup_steps.rb +0 -258
  22. data/testing/cucumber/step_definitions/verification_steps.rb +0 -94
  23. data/testing/file_helper.rb +0 -41
  24. data/testing/formatter_factory.rb +0 -15
  25. data/testing/gemfiles/cuke_modeler1.gemfile +0 -8
  26. data/testing/gemfiles/cuke_modeler2.gemfile +0 -8
  27. data/testing/linter_factory.rb +0 -60
  28. data/testing/model_factory.rb +0 -109
  29. data/testing/rspec/spec/integration/cli_integration_spec.rb +0 -556
  30. data/testing/rspec/spec/integration/configuration_spec.rb +0 -811
  31. data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +0 -243
  32. data/testing/rspec/spec/integration/formatters/formatter_integration_specs.rb +0 -5
  33. data/testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb +0 -8
  34. data/testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb +0 -8
  35. data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +0 -8
  36. data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +0 -8
  37. data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +0 -8
  38. data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +0 -8
  39. data/testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb +0 -8
  40. data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +0 -8
  41. data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +0 -8
  42. data/testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb +0 -8
  43. data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +0 -8
  44. data/testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb +0 -8
  45. data/testing/rspec/spec/integration/linters/linter_integration_spec.rb +0 -8
  46. data/testing/rspec/spec/integration/linters/linter_integration_specs.rb +0 -7
  47. data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +0 -8
  48. data/testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb +0 -8
  49. data/testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb +0 -8
  50. data/testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb +0 -8
  51. data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +0 -8
  52. data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +0 -8
  53. data/testing/rspec/spec/integration/linters/test_with_bad_name_integration_spec.rb +0 -8
  54. data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +0 -8
  55. data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +0 -8
  56. data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +0 -8
  57. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +0 -8
  58. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +0 -8
  59. data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +0 -8
  60. data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +0 -8
  61. data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +0 -114
  62. data/testing/rspec/spec/unit/formatters/formatter_unit_specs.rb +0 -11
  63. data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +0 -115
  64. data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +0 -186
  65. data/testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb +0 -11
  66. data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +0 -248
  67. data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +0 -203
  68. data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +0 -296
  69. data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +0 -81
  70. data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +0 -106
  71. data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +0 -124
  72. data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +0 -293
  73. data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +0 -80
  74. data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +0 -84
  75. data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +0 -102
  76. data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +0 -197
  77. data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +0 -57
  78. data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +0 -184
  79. data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +0 -89
  80. data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +0 -54
  81. data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +0 -155
  82. data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +0 -464
  83. data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -165
  84. data/testing/rspec/spec/unit/linters/test_with_bad_name_linter_unit_spec.rb +0 -81
  85. data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +0 -244
  86. data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +0 -88
  87. data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +0 -246
  88. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -233
  89. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -233
  90. data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -164
  91. data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
@@ -1,11 +0,0 @@
1
- shared_examples_for 'a configurable linter at the unit level' do
2
-
3
- it 'is configurable' do
4
- expect(subject).to respond_to(:configure)
5
- end
6
-
7
- it 'is configured via a set of options' do
8
- expect(subject.method(:configure).arity).to eq(1)
9
- end
10
-
11
- end
@@ -1,248 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::ElementWithCommonTagsLinter do
5
-
6
- let(:model_file_path) { 'some_file_path' }
7
-
8
- it_should_behave_like 'a linter at the unit level'
9
-
10
-
11
- it 'has a name' do
12
- expect(subject.name).to eq('ElementWithCommonTagsLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- ELEMENTS_WITH_TAGGABLE_CHILDREN.each do |model_type|
18
-
19
- context "with a #{model_type} that has common tags on all of its children" do
20
-
21
- let(:test_model) do
22
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
23
-
24
- 2.times do
25
- child_model = CukeLinter::ModelFactory.generate_lintable_model
26
- child_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@same')]
27
-
28
- case model_type
29
- when 'feature'
30
- model.tests << child_model
31
- when 'outline'
32
- model.examples << child_model
33
- else
34
- raise(ArgumentError, "Don't know how to setup a '#{model_type}'. Add a new case?")
35
- end
36
-
37
- end
38
-
39
- model
40
- end
41
-
42
- it_should_behave_like 'a linter linting a bad model'
43
-
44
-
45
- it 'records a problem' do
46
- result = subject.lint(test_model)
47
-
48
- case model_type
49
- when 'feature'
50
- expect(result[:problem]).to match(/^All tests in Feature have tag '@\w+'\. Move tag to Feature level\.$/)
51
- when 'outline'
52
- expect(result[:problem]).to match(/^All Examples in Outline have tag '@\w+'\. Move tag to Outline level\.$/)
53
- else
54
- raise(ArgumentError, "Don't know how to verify a '#{model_type}'. Add a new case?")
55
- end
56
- end
57
-
58
- it 'includes the name of the common tag found in the problem record' do
59
- common_tag = test_model.children.first.tags.first.name
60
- result = subject.lint(test_model)
61
- expect(result[:problem]).to match(/have tag '#{common_tag}'\./)
62
-
63
- test_model.children.first.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@still_same')]
64
- test_model.children.last.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@still_same')]
65
-
66
- common_tag = test_model.children.first.tags.first.name
67
- result = subject.lint(test_model)
68
- expect(result[:problem]).to match(/have tag '#{common_tag}'\./)
69
- end
70
-
71
- end
72
-
73
- context "with a #{model_type} that does not have common tags on all of its children" do
74
-
75
- context 'because none of their tags are common' do
76
-
77
- let(:test_model) do
78
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
79
-
80
- 2.times do |count|
81
- child_model = CukeLinter::ModelFactory.generate_lintable_model
82
- child_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: "@tag_#{count}")]
83
-
84
- case model_type
85
- when 'feature'
86
- model.tests << child_model
87
- when 'outline'
88
- model.examples << child_model
89
- else
90
- raise(ArgumentError, "Don't know how to setup a '#{model_type}'. Add a new case?")
91
- end
92
-
93
- end
94
-
95
- model
96
- end
97
-
98
- it_should_behave_like 'a linter linting a good model'
99
-
100
- end
101
-
102
- context 'because some of them have no tags' do
103
-
104
- context 'because their tags are empty' do
105
-
106
- let(:test_model) do
107
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
108
-
109
- 2.times do
110
- child_model = CukeLinter::ModelFactory.generate_lintable_model
111
- child_model.tags = []
112
-
113
- case model_type
114
- when 'feature'
115
- model.tests << child_model
116
- when 'outline'
117
- model.examples << child_model
118
- else
119
- raise(ArgumentError, "Don't know how to setup a '#{model_type}'. Add a new case?")
120
- end
121
-
122
- end
123
-
124
- model
125
- end
126
-
127
- it_should_behave_like 'a linter linting a good model'
128
-
129
- end
130
-
131
- context 'because their tags are nil' do
132
-
133
- let(:test_model) do
134
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
135
-
136
- 2.times do
137
- child_model = CukeLinter::ModelFactory.generate_lintable_model
138
- child_model.tags = nil
139
-
140
- case model_type
141
- when 'feature'
142
- model.tests << child_model
143
- when 'outline'
144
- model.examples << child_model
145
- else
146
- raise(ArgumentError, "Don't know how to setup a '#{model_type}'. Add a new case?")
147
- end
148
-
149
- end
150
-
151
- model
152
- end
153
-
154
- it_should_behave_like 'a linter linting a good model'
155
-
156
- end
157
-
158
- end
159
-
160
- context 'because the model only has one child' do
161
-
162
- let(:test_model) do
163
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
164
-
165
- 1.times do
166
- child_model = CukeLinter::ModelFactory.generate_lintable_model
167
- child_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@a_tag')]
168
-
169
- case model_type
170
- when 'feature'
171
- model.tests << child_model
172
- when 'outline'
173
- model.examples << child_model
174
- else
175
- raise(ArgumentError, "Don't know how to setup a '#{model_type}'. Add a new case?")
176
- end
177
-
178
- end
179
-
180
- model
181
- end
182
-
183
- it_should_behave_like 'a linter linting a good model'
184
-
185
- end
186
-
187
- context 'because the model has no children' do
188
-
189
- context 'because the children are empty' do
190
-
191
- let(:test_model) do
192
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
193
-
194
- case model_type
195
- when 'feature'
196
- model.tests = []
197
- when 'outline'
198
- model.examples = []
199
- else
200
- raise(ArgumentError, "Don't know how to setup a '#{model_type}'. Add a new case?")
201
- end
202
-
203
- model
204
- end
205
-
206
- it_should_behave_like 'a linter linting a good model'
207
-
208
- end
209
-
210
- context 'because the children are nil' do
211
-
212
- let(:test_model) do
213
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
214
-
215
- case model_type
216
- when 'feature'
217
- model.tests = nil
218
- when 'outline'
219
- model.examples = nil
220
- else
221
- raise(ArgumentError, "Don't know how to setup a '#{model_type}'. Add a new case?")
222
- end
223
-
224
- model
225
- end
226
-
227
- it_should_behave_like 'a linter linting a good model'
228
-
229
- end
230
-
231
- end
232
-
233
- end
234
-
235
- end
236
-
237
-
238
- context 'a model that is not a type that has taggable children' do
239
-
240
- let(:test_model) { CukeModeler::Model.new }
241
-
242
- it_should_behave_like 'a linter linting a good model'
243
-
244
- end
245
-
246
- end
247
-
248
- end
@@ -1,203 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::ElementWithDuplicateTagsLinter do
5
-
6
- let(:model_file_path) { 'some_file_path' }
7
-
8
- it_should_behave_like 'a linter at the unit level'
9
- it_should_behave_like 'a configurable linter at the unit level'
10
-
11
-
12
- it 'has a name' do
13
- expect(subject.name).to eq('ElementWithDuplicateTagsLinter')
14
- end
15
-
16
- describe 'linting' do
17
-
18
- TAGGABLE_ELEMENTS.each do |model_type|
19
-
20
- context "with a #{model_type} that has duplicate tags" do
21
-
22
- let(:test_model) do
23
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
24
- model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@same'),
25
- CukeLinter::ModelFactory.generate_tag_model(source_text: '@same')]
26
-
27
- model
28
- end
29
-
30
- it_should_behave_like 'a linter linting a bad model'
31
-
32
-
33
- it 'records a problem' do
34
- result = subject.lint(test_model)
35
-
36
- expect(result[:problem]).to match(/^#{model_type.capitalize} has duplicate tag '@\w+'\.$/)
37
- end
38
-
39
- it 'includes the name of the duplicate tag found in the problem record' do
40
- duplicate_tag = test_model.tags.first.name
41
- result = subject.lint(test_model)
42
- expect(result[:problem]).to eq("#{model_type.capitalize} has duplicate tag '#{duplicate_tag}'.")
43
-
44
- test_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@still_same'),
45
- CukeLinter::ModelFactory.generate_tag_model(source_text: '@still_same')]
46
-
47
- duplicate_tag = test_model.tags.first.name
48
- result = subject.lint(test_model)
49
- expect(result[:problem]).to eq("#{model_type.capitalize} has duplicate tag '#{duplicate_tag}'.")
50
- end
51
-
52
- end
53
-
54
- context "with a #{model_type} that does not have duplicate tags" do
55
-
56
- context 'because none of it tags are duplicates' do
57
-
58
- let(:test_model) do
59
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
60
- model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@foo'),
61
- CukeLinter::ModelFactory.generate_tag_model(source_text: '@bar')]
62
-
63
- model
64
- end
65
-
66
- it_should_behave_like 'a linter linting a good model'
67
-
68
- end
69
-
70
- context 'because it has no tags' do
71
-
72
- context 'because its tags are empty' do
73
-
74
- let(:test_model) do
75
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
76
- model.tags = []
77
-
78
- model
79
- end
80
-
81
- it_should_behave_like 'a linter linting a good model'
82
-
83
- end
84
-
85
- context 'because its tags are nil' do
86
-
87
- let(:test_model) do
88
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
89
- model.tags = nil
90
-
91
- model
92
- end
93
-
94
- it_should_behave_like 'a linter linting a good model'
95
-
96
- end
97
-
98
- end
99
-
100
- end
101
-
102
-
103
- describe 'configuration' do
104
-
105
- describe 'tag inheritance configuration' do
106
-
107
- let(:test_model_with_inherited_tags) do
108
- test_model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
109
- test_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@same')]
110
-
111
- distant_ancestor_model = CukeLinter::ModelFactory.generate_lintable_model
112
- distant_ancestor_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@same')]
113
- ancestor_model = CukeLinter::ModelFactory.generate_lintable_model
114
-
115
- # Adding an extra ancestor in the chain in order to make sure that the linter isn't just checking the parent model
116
- ancestor_model.parent_model = distant_ancestor_model
117
- test_model.parent_model = ancestor_model
118
-
119
- test_model
120
- end
121
-
122
-
123
- context 'with no configuration' do
124
-
125
- context 'because configuration never happened' do
126
-
127
- it 'does not include inherited tags' do
128
- result = subject.lint(test_model_with_inherited_tags)
129
-
130
- expect(result).to eq(nil)
131
- end
132
-
133
- end
134
-
135
- context 'because configuration did not set tag inheritance' do
136
-
137
- let(:configuration) { {} }
138
-
139
- before(:each) do
140
- subject.configure(configuration)
141
- end
142
-
143
- it 'does not include inherited tags' do
144
- result = subject.lint(test_model_with_inherited_tags)
145
-
146
- expect(result).to eq(nil)
147
- end
148
-
149
- end
150
-
151
- end
152
-
153
- context 'with configuration' do
154
-
155
- before(:each) do
156
- subject.configure(configuration)
157
- end
158
-
159
- context 'enabling tag inheritance' do
160
-
161
- let(:configuration) { { 'IncludeInheritedTags' => true } }
162
-
163
- it 'does include inherited tags' do
164
- result = subject.lint(test_model_with_inherited_tags)
165
-
166
- expect(result).to_not be_nil
167
- expect(result[:problem]).to match(/#{model_type.capitalize} has duplicate tag '@\w+'\./)
168
- end
169
-
170
- end
171
-
172
- context 'disabling tag inheritance' do
173
-
174
- let(:configuration) { { 'IncludeInheritedTags' => false } }
175
-
176
- it 'does not include inherited tags' do
177
- result = subject.lint(test_model_with_inherited_tags)
178
-
179
- expect(result).to eq(nil)
180
- end
181
-
182
- end
183
-
184
- end
185
-
186
- end
187
-
188
- end
189
-
190
- end
191
-
192
-
193
- context 'a non-taggable model' do
194
-
195
- let(:test_model) { CukeModeler::Model.new }
196
-
197
- it_should_behave_like 'a linter linting a good model'
198
-
199
- end
200
-
201
- end
202
-
203
- end