cuke_linter 0.12.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -1
  3. data/README.md +12 -8
  4. data/cuke_linter.gemspec +25 -21
  5. data/exe/cuke_linter +3 -1
  6. data/lib/cuke_linter.rb +119 -176
  7. data/lib/cuke_linter/configuration.rb +45 -0
  8. data/lib/cuke_linter/default_linters.rb +32 -0
  9. data/lib/cuke_linter/formatters/pretty_formatter.rb +63 -35
  10. data/lib/cuke_linter/gherkin.rb +10 -0
  11. data/lib/cuke_linter/linter_registration.rb +32 -0
  12. data/lib/cuke_linter/linters/background_does_more_than_setup_linter.rb +17 -1
  13. data/lib/cuke_linter/linters/element_with_common_tags_linter.rb +23 -14
  14. data/lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb +18 -13
  15. data/lib/cuke_linter/linters/element_with_too_many_tags_linter.rb +17 -11
  16. data/lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb +1 -3
  17. data/lib/cuke_linter/linters/feature_without_description_linter.rb +1 -1
  18. data/lib/cuke_linter/linters/linter.rb +17 -13
  19. data/lib/cuke_linter/linters/step_with_too_many_characters_linter.rb +2 -2
  20. data/lib/cuke_linter/linters/test_should_use_background_linter.rb +56 -4
  21. data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +12 -1
  22. data/lib/cuke_linter/linters/test_with_bad_name_linter.rb +4 -4
  23. data/lib/cuke_linter/linters/test_with_no_action_step_linter.rb +12 -1
  24. data/lib/cuke_linter/linters/test_with_no_verification_step_linter.rb +12 -1
  25. data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +18 -2
  26. data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +18 -2
  27. data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +12 -1
  28. data/lib/cuke_linter/version.rb +1 -1
  29. data/testing/cucumber/features/linters/background_does_more_than_setup.feature +34 -0
  30. data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +25 -3
  31. data/testing/cucumber/features/linters/test_with_no_action_step.feature +27 -1
  32. data/testing/cucumber/features/linters/test_with_no_verification_step.feature +28 -1
  33. data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +28 -1
  34. data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +28 -1
  35. data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +25 -3
  36. metadata +88 -106
  37. data/.gitignore +0 -19
  38. data/.simplecov +0 -8
  39. data/.travis.yml +0 -23
  40. data/CONTRIBUTING.md +0 -26
  41. data/Gemfile +0 -6
  42. data/Rakefile +0 -63
  43. data/appveyor.yml +0 -43
  44. data/bin/console +0 -14
  45. data/bin/setup +0 -8
  46. data/environments/common_env.rb +0 -12
  47. data/environments/cucumber_env.rb +0 -22
  48. data/environments/rspec_env.rb +0 -50
  49. data/testing/cucumber/step_definitions/action_steps.rb +0 -84
  50. data/testing/cucumber/step_definitions/setup_steps.rb +0 -230
  51. data/testing/cucumber/step_definitions/verification_steps.rb +0 -94
  52. data/testing/file_helper.rb +0 -41
  53. data/testing/formatter_factory.rb +0 -15
  54. data/testing/gemfiles/cuke_modeler1.gemfile +0 -8
  55. data/testing/gemfiles/cuke_modeler2.gemfile +0 -8
  56. data/testing/linter_factory.rb +0 -60
  57. data/testing/model_factory.rb +0 -109
  58. data/testing/rspec/spec/integration/cli_integration_spec.rb +0 -556
  59. data/testing/rspec/spec/integration/configuration_spec.rb +0 -811
  60. data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +0 -243
  61. data/testing/rspec/spec/integration/formatters/formatter_integration_specs.rb +0 -5
  62. data/testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb +0 -8
  63. data/testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb +0 -8
  64. data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +0 -8
  65. data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +0 -8
  66. data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +0 -8
  67. data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +0 -8
  68. data/testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb +0 -8
  69. data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +0 -8
  70. data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +0 -8
  71. data/testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb +0 -8
  72. data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +0 -8
  73. data/testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb +0 -8
  74. data/testing/rspec/spec/integration/linters/linter_integration_spec.rb +0 -8
  75. data/testing/rspec/spec/integration/linters/linter_integration_specs.rb +0 -7
  76. data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +0 -8
  77. data/testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb +0 -8
  78. data/testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb +0 -8
  79. data/testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb +0 -8
  80. data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +0 -8
  81. data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +0 -8
  82. data/testing/rspec/spec/integration/linters/test_with_bad_name_integration_spec.rb +0 -8
  83. data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +0 -8
  84. data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +0 -8
  85. data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +0 -8
  86. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +0 -8
  87. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +0 -8
  88. data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +0 -8
  89. data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +0 -8
  90. data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +0 -102
  91. data/testing/rspec/spec/unit/formatters/formatter_unit_specs.rb +0 -11
  92. data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +0 -115
  93. data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +0 -77
  94. data/testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb +0 -11
  95. data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +0 -248
  96. data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +0 -203
  97. data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +0 -296
  98. data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +0 -81
  99. data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +0 -106
  100. data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +0 -124
  101. data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +0 -293
  102. data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +0 -80
  103. data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +0 -84
  104. data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +0 -102
  105. data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +0 -197
  106. data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +0 -57
  107. data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +0 -184
  108. data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +0 -89
  109. data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +0 -54
  110. data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +0 -155
  111. data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +0 -226
  112. data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -98
  113. data/testing/rspec/spec/unit/linters/test_with_bad_name_linter_unit_spec.rb +0 -81
  114. data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +0 -176
  115. data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +0 -88
  116. data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +0 -179
  117. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -124
  118. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -125
  119. data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -98
  120. data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
@@ -1,57 +0,0 @@
1
- shared_examples_for 'a linter at the unit level' do
2
-
3
- it 'is named' do
4
- expect(subject).to respond_to(:name)
5
- expect(subject.name).to be_a_kind_of(String)
6
- expect(subject.name).to_not be_empty
7
- end
8
-
9
- it 'can lint' do
10
- expect(subject).to respond_to(:lint)
11
- end
12
-
13
- it 'lints a model' do
14
- expect(subject.method(:lint).arity).to eq(1)
15
- end
16
-
17
- end
18
-
19
-
20
- shared_examples_for 'a linter linting a good model' do
21
-
22
- it 'returns no problem' do
23
- expect(subject.lint(test_model)).to be_nil
24
- end
25
-
26
- end
27
-
28
-
29
- shared_examples_for 'a linter linting a bad model' do
30
-
31
- it 'returns a detected problem' do
32
- expect(subject.lint(test_model)).to_not be_nil
33
- end
34
-
35
- it 'includes the problem and its location in its result' do
36
- result = subject.lint(test_model)
37
-
38
- expect(result).to_not be_nil
39
- expect(result.keys).to match_array([:problem, :location])
40
- end
41
-
42
- it 'correctly records the location of the problem' do
43
- if test_model.is_a?(CukeModeler::FeatureFile)
44
- result = subject.lint(test_model)
45
- expect(result[:location]).to eq("#{model_file_path}")
46
- else
47
- test_model.source_line = 1
48
- result = subject.lint(test_model)
49
- expect(result[:location]).to eq("#{model_file_path}:1")
50
-
51
- test_model.source_line = 3
52
- result = subject.lint(test_model)
53
- expect(result[:location]).to eq("#{model_file_path}:3")
54
- end
55
- end
56
-
57
- end
@@ -1,184 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::OutlineWithSingleExampleRowLinter 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('OutlineWithSingleExampleRowLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- context 'an outline with only one example row' do
18
-
19
- context 'with only one example set' do
20
-
21
- let(:test_model) do
22
- gherkin = 'Scenario Outline:
23
- * a step
24
- Examples:
25
- | param |
26
- | value |'
27
-
28
- CukeLinter::ModelFactory.generate_outline_model(parent_file_path: model_file_path,
29
- source_text: gherkin)
30
- end
31
-
32
- it_should_behave_like 'a linter linting a bad model'
33
-
34
-
35
- it 'records a problem' do
36
- result = subject.lint(test_model)
37
-
38
- expect(result[:problem]).to eq('Outline has only one example row')
39
- end
40
-
41
- end
42
-
43
- context 'with multiple example sets' do
44
-
45
- let(:test_model) do
46
- gherkin = 'Scenario Outline:
47
- * a step
48
- Examples:
49
- | param |
50
- Examples:
51
- | param |
52
- | value |'
53
-
54
- CukeLinter::ModelFactory.generate_outline_model(parent_file_path: model_file_path,
55
- source_text: gherkin)
56
- end
57
-
58
- it_should_behave_like 'a linter linting a bad model'
59
-
60
-
61
- it 'records a problem' do
62
- result = subject.lint(test_model)
63
-
64
- expect(result[:problem]).to eq('Outline has only one example row')
65
- end
66
-
67
- end
68
-
69
- end
70
-
71
- context 'an outline with more than one example row' do
72
-
73
- context 'with only one example set' do
74
-
75
- let(:test_model) do
76
- gherkin = 'Scenario Outline:
77
- * a step
78
- Examples:
79
- | param |
80
- | value 1 |
81
- | value 2 |'
82
-
83
- CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
84
- end
85
-
86
- it_should_behave_like 'a linter linting a good model'
87
-
88
- end
89
-
90
- context 'with multiple example sets' do
91
-
92
- let(:test_model) do
93
- gherkin = 'Scenario Outline:
94
- * a step
95
- Examples:
96
- | param |
97
- | value 1 |
98
- Examples:
99
- | param |
100
- | value 1 |'
101
-
102
- CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
103
- end
104
-
105
- it_should_behave_like 'a linter linting a good model'
106
-
107
- end
108
-
109
- end
110
-
111
- context 'an outline with no example rows' do
112
-
113
- context 'because it has no example sets' do
114
-
115
- context 'because its examples are nil' do
116
-
117
- let(:test_model) do
118
- model = CukeLinter::ModelFactory.generate_outline_model
119
- model.examples = nil
120
-
121
- model
122
- end
123
-
124
- it_should_behave_like 'a linter linting a good model'
125
-
126
- end
127
-
128
- context 'because its examples are empty' do
129
- let(:test_model) do
130
- model = CukeLinter::ModelFactory.generate_outline_model
131
- model.examples = []
132
-
133
- model
134
- end
135
-
136
- it_should_behave_like 'a linter linting a good model'
137
-
138
- end
139
-
140
- end
141
-
142
- context 'with only one example set' do
143
-
144
- let(:test_model) do
145
- gherkin = 'Scenario Outline:
146
- * a step
147
- Examples:
148
- | param |'
149
-
150
- CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
151
- end
152
-
153
- it_should_behave_like 'a linter linting a good model'
154
-
155
- end
156
-
157
- context 'with multiple example sets' do
158
-
159
- let(:test_model) do
160
- gherkin = 'Scenario Outline:
161
- * a step
162
- Examples:
163
- | param |
164
- Examples:
165
- | param |'
166
-
167
- CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
168
- end
169
-
170
- it_should_behave_like 'a linter linting a good model'
171
-
172
- end
173
-
174
- end
175
-
176
- context 'a non-outline model' do
177
-
178
- let(:test_model) { CukeModeler::Model.new }
179
-
180
- it_should_behave_like 'a linter linting a good model'
181
-
182
- end
183
- end
184
- end
@@ -1,89 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::SingleTestBackgroundLinter 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('SingleTestBackgroundLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- context 'with a background that affects only one test' do
18
-
19
- ['scenario', 'outline'].each do |model_type|
20
-
21
- context "and that test is a #{model_type}" do
22
-
23
- let(:test_model) do
24
- background_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
25
- source_text: 'Feature:
26
- Background:
27
- * a step').background
28
-
29
- background_model.parent_model.tests.clear
30
- background_model.parent_model.tests << CukeLinter::ModelFactory.send("generate_#{model_type}_model")
31
-
32
- background_model
33
- end
34
-
35
- it_should_behave_like 'a linter linting a bad model'
36
-
37
-
38
- it 'records a problem' do
39
- result = subject.lint(test_model)
40
-
41
- expect(result[:problem]).to match('Background used with only one test')
42
- end
43
-
44
- end
45
-
46
- end
47
-
48
- end
49
-
50
- context 'with a background that affects multiple tests' do
51
-
52
- let(:test_model) do
53
- CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:
54
- Background:
55
- * a step
56
- Scenario:
57
- Scenario Outline:
58
- * a step
59
- Examples:
60
- |param|
61
- |value|').background
62
- end
63
-
64
- it_should_behave_like 'a linter linting a good model'
65
-
66
- end
67
-
68
- context 'with a background that affects no tests' do
69
-
70
- let(:test_model) do
71
- CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:
72
- Background:
73
- * a step').background
74
- end
75
-
76
- it_should_behave_like 'a linter linting a good model'
77
-
78
- end
79
-
80
- context 'with a non-background model' do
81
-
82
- let(:test_model) { CukeModeler::Model.new }
83
-
84
- it_should_behave_like 'a linter linting a good model'
85
-
86
- end
87
-
88
- end
89
- end
@@ -1,54 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::StepWithEndPeriodLinter 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('StepWithEndPeriodLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- context "with a step that ends with a period" do
18
-
19
- let(:test_model) do
20
- CukeLinter::ModelFactory.generate_step_model(parent_file_path: model_file_path,
21
- source_text: '* with a period.')
22
- end
23
-
24
- it_should_behave_like 'a linter linting a bad model'
25
-
26
-
27
- it 'records a problem' do
28
- result = subject.lint(test_model)
29
-
30
- expect(result[:problem]).to match('Step ends with a period')
31
- end
32
-
33
- end
34
-
35
- context "with a step that does not end with a period" do
36
-
37
- let(:test_model) do
38
- CukeLinter::ModelFactory.generate_step_model(source_text: '* without a period')
39
- end
40
-
41
- it_should_behave_like 'a linter linting a good model'
42
-
43
- end
44
-
45
- context 'with a non-step model' do
46
-
47
- let(:test_model) { CukeModeler::Model.new }
48
-
49
- it_should_behave_like 'a linter linting a good model'
50
-
51
- end
52
-
53
- end
54
- end
@@ -1,155 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::StepWithTooManyCharactersLinter 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('StepWithTooManyCharactersLinter')
14
- end
15
-
16
- describe 'linting' do
17
-
18
- let(:default_character_threshold) { 80 }
19
-
20
- context 'when the step is too long' do
21
-
22
- let(:test_model) do
23
- step = 'x' * (default_character_threshold + 1)
24
- CukeLinter::ModelFactory.generate_step_model(parent_file_path: model_file_path,
25
- source_text: "* #{step}")
26
- end
27
-
28
- it_should_behave_like 'a linter linting a bad model'
29
-
30
-
31
- it 'reports a problem' do
32
- result = subject.lint(test_model)
33
-
34
- expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 80\)/)
35
- end
36
-
37
- it 'includes the number of characters found in the problem record' do
38
- character_count = test_model.text.length
39
- result = subject.lint(test_model)
40
- expect(result[:problem]).to eq("Step is too long. #{character_count} characters found (max 80)")
41
-
42
- test_model.text += 'x'
43
- result = subject.lint(test_model)
44
- expect(result[:problem]).to eq("Step is too long. #{character_count + 1} characters found (max 80)")
45
- end
46
-
47
- end
48
-
49
- context 'when the step is the maximum length' do
50
-
51
- let(:test_model) do
52
- step = 'x' * default_character_threshold
53
- CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
54
- end
55
-
56
- it_should_behave_like 'a linter linting a good model'
57
-
58
- end
59
-
60
- context 'when the step is below the maximum length' do
61
-
62
- let(:test_model) do
63
- step = 'x' * (default_character_threshold - 1)
64
- CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
65
- end
66
-
67
- it_should_behave_like 'a linter linting a good model'
68
-
69
- end
70
-
71
- context 'when the step has no text' do
72
-
73
- let(:test_model) do
74
- model = CukeLinter::ModelFactory.generate_step_model
75
- model.text = nil
76
-
77
- model
78
- end
79
-
80
- it_should_behave_like 'a linter linting a good model'
81
-
82
- end
83
-
84
- context 'a non-step model' do
85
-
86
- let(:test_model) { CukeModeler::Model.new }
87
-
88
- it_should_behave_like 'a linter linting a good model'
89
-
90
- end
91
-
92
- end
93
-
94
- describe 'configuration' do
95
-
96
- context 'with no configuration' do
97
-
98
- let(:default_character_threshold) { 80 }
99
-
100
- context 'because configuration never happened' do
101
-
102
- let(:default_model) do
103
- step = 'x' * (default_character_threshold + 1)
104
- CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
105
- end
106
-
107
- it 'defaults to a maximum of 80 characters' do
108
- result = subject.lint(default_model)
109
-
110
- expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 80\)/)
111
- end
112
-
113
- end
114
-
115
- context 'because configuration did not set a step threshold' do
116
- let(:configuration) { {} }
117
- let(:configured_model) do
118
- subject.configure(configuration)
119
- step = 'x' * (default_character_threshold + 1)
120
- CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
121
- end
122
-
123
- it 'defaults to a maximum of 80 characters' do
124
- result = subject.lint(configured_model)
125
-
126
- expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 80\)/)
127
- end
128
-
129
- end
130
-
131
- end
132
-
133
- context 'when configured' do
134
- let(:character_threshold) { 10 }
135
- let(:configuration) { { 'StepLengthThreshold' => character_threshold } }
136
-
137
- subject { linter = CukeLinter::StepWithTooManyCharactersLinter.new
138
- linter.configure(configuration)
139
- linter }
140
-
141
- let(:test_model) do
142
- step = 'x' * (character_threshold + 1)
143
- CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
144
- end
145
-
146
- it 'uses the maximum character length provided by configuration' do
147
- result = subject.lint(test_model)
148
-
149
- expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 10\)/)
150
- end
151
-
152
- end
153
-
154
- end
155
- end