cuke_linter 0.13.0 → 1.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +4 -4
- data/cuke_linter.gemspec +3 -3
- data/lib/cuke_linter.rb +5 -3
- data/lib/cuke_linter/version.rb +1 -1
- metadata +2 -86
- data/.gitignore +0 -19
- data/.simplecov +0 -8
- data/.travis.yml +0 -33
- data/CONTRIBUTING.md +0 -26
- data/Gemfile +0 -6
- data/Rakefile +0 -63
- data/appveyor.yml +0 -43
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/environments/common_env.rb +0 -12
- data/environments/cucumber_env.rb +0 -22
- data/environments/rspec_env.rb +0 -50
- data/testing/cucumber/step_definitions/action_steps.rb +0 -84
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -258
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -94
- data/testing/file_helper.rb +0 -41
- data/testing/formatter_factory.rb +0 -15
- data/testing/gemfiles/cuke_modeler1.gemfile +0 -8
- data/testing/gemfiles/cuke_modeler2.gemfile +0 -8
- data/testing/linter_factory.rb +0 -60
- data/testing/model_factory.rb +0 -109
- data/testing/rspec/spec/integration/cli_integration_spec.rb +0 -556
- data/testing/rspec/spec/integration/configuration_spec.rb +0 -811
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +0 -243
- data/testing/rspec/spec/integration/formatters/formatter_integration_specs.rb +0 -5
- data/testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/linter_integration_specs.rb +0 -7
- data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_bad_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +0 -114
- data/testing/rspec/spec/unit/formatters/formatter_unit_specs.rb +0 -11
- data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +0 -115
- data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +0 -186
- data/testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb +0 -11
- data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +0 -248
- data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +0 -203
- data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +0 -296
- data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +0 -81
- data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +0 -106
- data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +0 -124
- data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +0 -293
- data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +0 -80
- data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +0 -84
- data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +0 -102
- data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +0 -197
- data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +0 -57
- data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +0 -184
- data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +0 -89
- data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +0 -54
- data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +0 -155
- data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +0 -464
- data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -165
- data/testing/rspec/spec/unit/linters/test_with_bad_name_linter_unit_spec.rb +0 -81
- data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +0 -244
- data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +0 -88
- data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +0 -246
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -233
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -233
- data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -164
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
data/bin/setup
DELETED
data/environments/common_env.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require 'require_all'
|
|
2
|
-
|
|
3
|
-
require 'cuke_linter'
|
|
4
|
-
require 'open3'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require_relative '../testing/model_factory'
|
|
8
|
-
require_relative '../testing/linter_factory'
|
|
9
|
-
require_relative '../testing/formatter_factory'
|
|
10
|
-
require_relative '../testing/file_helper'
|
|
11
|
-
|
|
12
|
-
PROJECT_ROOT = "#{__dir__}/.."
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require 'simplecov'
|
|
2
|
-
SimpleCov.command_name('cucumber_tests')
|
|
3
|
-
|
|
4
|
-
require_relative 'common_env'
|
|
5
|
-
require 'cucumber'
|
|
6
|
-
|
|
7
|
-
require_all 'testing/cucumber/step_definitions'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Before do
|
|
11
|
-
CukeLinter.clear_registered_linters
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
Before do
|
|
15
|
-
@root_test_directory = CukeLinter::FileHelper.create_directory
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
at_exit do
|
|
19
|
-
CukeLinter::FileHelper.created_directories.each do |dir_path|
|
|
20
|
-
FileUtils.remove_entry(dir_path, true)
|
|
21
|
-
end
|
|
22
|
-
end
|
data/environments/rspec_env.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'simplecov'
|
|
2
|
-
SimpleCov.command_name('rspec_tests')
|
|
3
|
-
|
|
4
|
-
require_relative 'common_env'
|
|
5
|
-
require 'rspec'
|
|
6
|
-
require 'rubygems/mock_gem_ui'
|
|
7
|
-
require 'yaml'
|
|
8
|
-
|
|
9
|
-
require_relative '../testing/rspec/spec/unit/formatters/formatter_unit_specs'
|
|
10
|
-
require_relative '../testing/rspec/spec/unit/linters/configurable_linter_unit_specs'
|
|
11
|
-
require_relative '../testing/rspec/spec/unit/linters/linter_unit_specs'
|
|
12
|
-
require_relative '../testing/rspec/spec/integration/formatters/formatter_integration_specs'
|
|
13
|
-
require_relative '../testing/rspec/spec/integration/linters/linter_integration_specs'
|
|
14
|
-
|
|
15
|
-
# Convenient constants, just in case what kinds of elements are taggable ever changes
|
|
16
|
-
TAGGABLE_ELEMENTS = ['feature', 'scenario', 'outline', 'example']
|
|
17
|
-
ELEMENTS_WITH_TAGGABLE_CHILDREN = ['feature', 'outline']
|
|
18
|
-
|
|
19
|
-
RSpec.configure do |config|
|
|
20
|
-
# Enable flags like --only-failures and --next-failure
|
|
21
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
|
22
|
-
|
|
23
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
24
|
-
config.disable_monkey_patching!
|
|
25
|
-
|
|
26
|
-
config.expect_with :rspec do |c|
|
|
27
|
-
c.syntax = :expect
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
config.before(:suite) do
|
|
31
|
-
# Using a global variable instead of an instance variable because instance variables are not compatible with :suite hooks
|
|
32
|
-
$default_linters = Marshal.load(Marshal.dump(CukeLinter.registered_linters))
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Restore the original linters after any test that modifies them so that other tests can rely on them being only the default ones
|
|
36
|
-
config.after(:example, :linter_registration) do
|
|
37
|
-
CukeLinter.clear_registered_linters
|
|
38
|
-
|
|
39
|
-
$default_linters.each_pair do |name, linter|
|
|
40
|
-
CukeLinter.register_linter(name: name, linter: linter)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
config.after(:suite) do
|
|
45
|
-
CukeLinter::FileHelper.created_directories.each do |dir_path|
|
|
46
|
-
FileUtils.remove_entry(dir_path, true)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
end
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
When(/^the following command is executed:$/) do |command|
|
|
2
|
-
command = "bundle exec ruby #{@executable_directory || "#{PROJECT_ROOT}/exe"}/#{command}"
|
|
3
|
-
command.gsub!('<path_to>', @root_test_directory)
|
|
4
|
-
|
|
5
|
-
@results = @output = `#{command}`
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
When(/^it is formatted by the "([^"]*)" formatter$/) do |linter_name|
|
|
9
|
-
@results = CukeLinter.const_get("#{linter_name.capitalize}Formatter").new.format(@linter_data)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
When(/^(?:the feature|the model|it) is linted$/) do
|
|
13
|
-
options = { model_trees: [@model],
|
|
14
|
-
formatters: [[CukeLinter::FormatterFactory.generate_fake_formatter, "#{CukeLinter::FileHelper::create_directory}/junk_output_file.txt"]] }
|
|
15
|
-
options[:linters] = [@linter] if @linter
|
|
16
|
-
|
|
17
|
-
@results = CukeLinter.lint(options)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
When(/^the configuration file is (?:used|loaded)$/) do
|
|
21
|
-
CukeLinter.load_configuration(config_file_path: @configuration_file_path)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
And(/^the following code is used:$/) do |code|
|
|
25
|
-
code.sub!('<path_to>', @root_test_directory)
|
|
26
|
-
code.sub!('<code_to_generate_a_new_linter_instance>', 'CukeLinter::LinterFactory.generate_fake_linter')
|
|
27
|
-
|
|
28
|
-
if @working_directory
|
|
29
|
-
Dir.chdir(@working_directory) do
|
|
30
|
-
eval(code)
|
|
31
|
-
end
|
|
32
|
-
else
|
|
33
|
-
eval(code)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
When(/^"([^"]*)" is the current directory$/) do |directory|
|
|
38
|
-
@working_directory = "#{@root_test_directory}/#{directory}"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
When(/^the executable finds no linting problems$/) do
|
|
42
|
-
# Linting an empty directory doesn't (currently) find and problems
|
|
43
|
-
command = "bundle exec ruby #{PROJECT_ROOT}/exe/cuke_linter"
|
|
44
|
-
|
|
45
|
-
std_out, std_err, status = [nil, nil, nil]
|
|
46
|
-
|
|
47
|
-
Dir.chdir(@root_test_directory) do
|
|
48
|
-
std_out, std_err, status = Open3.capture3(command)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
@results = { std_out: std_out, std_err: std_err, status: status }
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
When(/^the executable finds linting problems$/) do
|
|
55
|
-
# This should be a problematic feature file
|
|
56
|
-
CukeLinter::FileHelper.create_file(directory: @root_test_directory,
|
|
57
|
-
name: 'pretty_empty',
|
|
58
|
-
extension: '.feature',
|
|
59
|
-
text: 'Feature: ')
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
command = "bundle exec ruby #{PROJECT_ROOT}/exe/cuke_linter"
|
|
63
|
-
|
|
64
|
-
std_out, std_err, status = [nil, nil, nil]
|
|
65
|
-
|
|
66
|
-
Dir.chdir(@root_test_directory) do
|
|
67
|
-
std_out, std_err, status = Open3.capture3(command)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
@results = { std_out: std_out, std_err: std_err, status: status }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
When(/^the executable has a problem$/) do
|
|
74
|
-
# Missing a required argument for a flag should be a problem
|
|
75
|
-
command = "bundle exec ruby #{PROJECT_ROOT}/exe/cuke_linter -r"
|
|
76
|
-
|
|
77
|
-
std_out, std_err, status = [nil, nil, nil]
|
|
78
|
-
|
|
79
|
-
Dir.chdir(@root_test_directory) do
|
|
80
|
-
std_out, std_err, status = Open3.capture3(command)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
@results = { std_out: std_out, std_err: std_err, status: status }
|
|
84
|
-
end
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
Given(/^the cuke_linter executable is available$/) do
|
|
2
|
-
@executable_directory = "#{PROJECT_ROOT}/exe"
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
Given(/^the following linter data:$/) do |linter_data|
|
|
6
|
-
@linter_data = [].tap do |data|
|
|
7
|
-
linter_data.hashes.each do |data_point|
|
|
8
|
-
data << { linter: data_point['linter name'],
|
|
9
|
-
problem: data_point['problem'],
|
|
10
|
-
location: data_point['location'] }
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
Given(/^the following feature:$/) do |text|
|
|
16
|
-
@model = CukeModeler::Feature.new(text)
|
|
17
|
-
|
|
18
|
-
fake_file_model = CukeModeler::FeatureFile.new
|
|
19
|
-
fake_file_model.path = 'path_to_file'
|
|
20
|
-
|
|
21
|
-
@model.parent_model = fake_file_model
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
Given(/^a linter for features without scenarios$/) do
|
|
25
|
-
@linter = CukeLinter::FeatureWithoutScenariosLinter.new
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
Given(/^a linter for features with invalid file names$/) do
|
|
29
|
-
@linter = CukeLinter::FeatureFileWithInvalidNameLinter.new
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
And(/^a linter for features with mismatched file names$/) do
|
|
33
|
-
@linter = CukeLinter::FeatureFileWithMismatchedNameLinter.new
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
Given(/^no other linters have been registered or unregistered$/) do
|
|
37
|
-
CukeLinter.reset_linters
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
Given(/^a linter for examples without names$/) do
|
|
41
|
-
@linter = CukeLinter::ExampleWithoutNameLinter.new
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
Given(/^a linter for outlines with only one example row$/) do
|
|
45
|
-
@linter = CukeLinter::OutlineWithSingleExampleRowLinter.new
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
Given("a linter for tests with bad names") do
|
|
49
|
-
@linter = CukeLinter::TestWithBadNameLinter.new
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
Given(/^a linter for tests with too many steps$/) do
|
|
53
|
-
@linter = CukeLinter::TestWithTooManyStepsLinter.new
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
Given(/^a linter for steps the end with a period$/) do
|
|
57
|
-
@linter = CukeLinter::StepWithEndPeriodLinter.new
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
Given(/^a linter for backgrounds applied to only one test$/) do
|
|
61
|
-
@linter = CukeLinter::SingleTestBackgroundLinter.new
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
Given(/^a linter for backgrounds that do more than setup$/) do
|
|
65
|
-
@linter = CukeLinter::BackgroundDoesMoreThanSetupLinter.new
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
Given("a linter for test steps with too many characters") do
|
|
69
|
-
@linter = CukeLinter::StepWithTooManyCharactersLinter.new
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
Given(/^a linter for tests with no action step$/) do
|
|
73
|
-
@linter = CukeLinter::TestWithNoActionStepLinter.new
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
Given(/^a linter for tests with no verification step$/) do
|
|
77
|
-
@linter = CukeLinter::TestWithNoVerificationStepLinter.new
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
Given(/^a linter for features without a name$/) do
|
|
81
|
-
@linter = CukeLinter::FeatureWithoutNameLinter.new
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
Given(/^a linter for elements with too many tags$/) do
|
|
85
|
-
@linter = CukeLinter::ElementWithTooManyTagsLinter.new
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
Given(/^a linter for features with too many different tags$/) do
|
|
89
|
-
@linter = CukeLinter::FeatureWithTooManyDifferentTagsLinter.new
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
Given(/^a linter for elements with too many tags has been registered$/) do
|
|
93
|
-
CukeLinter.register_linter(linter: CukeLinter::ElementWithTooManyTagsLinter.new, name: 'ElementWithTooManyTagsLinter')
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
Given(/^a linter for elements with duplicate tags has been registered$/) do
|
|
97
|
-
CukeLinter.register_linter(linter: CukeLinter::ElementWithDuplicateTagsLinter.new, name: 'ElementWithDuplicateTagsLinter')
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
Given(/^a linter for tests with too many steps has been registered$/) do
|
|
101
|
-
CukeLinter.register_linter(linter: CukeLinter::TestWithTooManyStepsLinter.new, name: 'TestWithTooManyStepsLinter')
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
Given(/^a linter for backgrounds that do more than setup has been registered$/) do
|
|
105
|
-
CukeLinter.register_linter(linter: CukeLinter::BackgroundDoesMoreThanSetupLinter.new, name: 'BackgroundDoesMoreThanSetupLinter')
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
Given(/^a linter for tests with an action step as the final step has been registered$/) do
|
|
109
|
-
CukeLinter.register_linter(linter: CukeLinter::TestWithActionStepAsFinalStepLinter.new, name: 'TestWithActionStepAsFinalStepLinter')
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
Given(/^a linter for tests with no action step has been registered$/) do
|
|
113
|
-
CukeLinter.register_linter(linter: CukeLinter::TestWithNoActionStepLinter.new, name: 'TestWithNoActionStepLinter')
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
Given(/^a linter for tests with no verification step has been registered$/) do
|
|
117
|
-
CukeLinter.register_linter(linter: CukeLinter::TestWithNoVerificationStepLinter.new, name: 'TestWithNoVerificationStepLinter')
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
Given(/^a linter for tests with a setup step after an action step has been registered$/) do
|
|
121
|
-
CukeLinter.register_linter(linter: CukeLinter::TestWithSetupStepAfterActionStepLinter.new, name: 'TestWithSetupStepAfterActionStepLinter')
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
Given(/^a linter for tests with a setup step after a verification step has been registered$/) do
|
|
125
|
-
CukeLinter.register_linter(linter: CukeLinter::TestWithSetupStepAfterVerificationStepLinter.new, name: 'TestWithSetupStepAfterVerificationStepLinter')
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
Given(/^a linter for tests with a setup step as the final step has been registered$/) do
|
|
129
|
-
CukeLinter.register_linter(linter: CukeLinter::TestWithSetupStepAsFinalStepLinter.new, name: 'TestWithSetupStepAsFinalStepLinter')
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
Given("a linter for features without a description") do
|
|
133
|
-
@linter = CukeLinter::FeatureWithoutDescriptionLinter.new
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
Given(/^a linter for tests with no name$/) do
|
|
137
|
-
@linter = CukeLinter::TestWithNoNameLinter.new
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
Given(/^a linter for tests that should use a background$/) do
|
|
141
|
-
@linter = CukeLinter::TestShouldUseBackgroundLinter.new
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
Given(/^a linter for tests with a setup step after an action step$/) do
|
|
145
|
-
@linter = CukeLinter::TestWithSetupStepAfterActionStepLinter.new
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
Given(/^a linter for tests with a setup step after a verification step$/) do
|
|
149
|
-
@linter = CukeLinter::TestWithSetupStepAfterVerificationStepLinter.new
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
Given(/^a linter for tests with a setup step as the final step$/) do
|
|
153
|
-
@linter = CukeLinter::TestWithSetupStepAsFinalStepLinter.new
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
Given(/^a linter for tests with an action step as the final step$/) do
|
|
157
|
-
@linter = CukeLinter::TestWithActionStepAsFinalStepLinter.new
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
Given(/^a linter for elements with duplicate tags$/) do
|
|
161
|
-
@linter = CukeLinter::ElementWithDuplicateTagsLinter.new
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
Given(/^a linter for elements with common tags$/) do
|
|
165
|
-
@linter = CukeLinter::ElementWithCommonTagsLinter.new
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
Given(/^a linter for test steps with too many characters has been registered$/) do
|
|
169
|
-
CukeLinter.register_linter(linter: CukeLinter::StepWithTooManyCharactersLinter.new, name: 'StepWithTooManyCharactersLinter')
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
Given(/^a linter for features with too many different tags has been registered$/) do
|
|
173
|
-
CukeLinter.register_linter(linter: CukeLinter::FeatureWithTooManyDifferentTagsLinter.new, name: 'FeatureWithTooManyDifferentTagsLinter')
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
Given(/^the following configuration file(?: "([^"]*)")?:$/) do |file_name, text|
|
|
177
|
-
file_name ||= '.cuke_linter'
|
|
178
|
-
|
|
179
|
-
@configuration_file_path = CukeLinter::FileHelper.create_file(directory: @root_test_directory, name: file_name, extension: '', text: text)
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
Given(/^a linter "([^"]*)"$/) do |linter_class|
|
|
183
|
-
@linter = CukeLinter.const_get(linter_class).new
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
Given(/^a linter registered as "([^"]*)"$/) do |linter_name|
|
|
187
|
-
CukeLinter.register_linter(linter: CukeLinter::LinterFactory.generate_fake_linter(name: linter_name), name: linter_name)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
Given(/^a directory "([^"]*)"$/) do |directory_name|
|
|
191
|
-
@test_directory = CukeLinter::FileHelper.create_directory(directory: @root_test_directory, name: directory_name)
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
Given(/^no linters are currently registered$/) do
|
|
195
|
-
CukeLinter.clear_registered_linters
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
Given(/^the following custom linter object:$/) do |code|
|
|
199
|
-
code.sub!('<path_to>', @root_test_directory)
|
|
200
|
-
code.sub!('<code_to_generate_a_new_linter_instance>', 'CukeLinter::LinterFactory.generate_fake_linter')
|
|
201
|
-
|
|
202
|
-
if @working_directory
|
|
203
|
-
Dir.chdir(@working_directory) do
|
|
204
|
-
eval(code)
|
|
205
|
-
end
|
|
206
|
-
else
|
|
207
|
-
eval(code)
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
And(/^a model to lint$/) do
|
|
212
|
-
# Any old model should be fine
|
|
213
|
-
@model = CukeModeler::Feature.new
|
|
214
|
-
|
|
215
|
-
fake_file_model = CukeModeler::FeatureFile.new
|
|
216
|
-
fake_file_model.path = 'path_to_file'
|
|
217
|
-
|
|
218
|
-
@model.parent_model = fake_file_model
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
Given(/^the following custom linter class:$/) do |code|
|
|
222
|
-
eval(code)
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
Given(/^the following(?: feature)? file "([^"]*)":$/) do |file_path, text|
|
|
226
|
-
path, extension = file_path.split('.')
|
|
227
|
-
|
|
228
|
-
@created_files ||= []
|
|
229
|
-
@created_files << CukeLinter::FileHelper.create_file(directory: @root_test_directory, name: path, extension: ".#{extension}", text: text)
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
Given(/^the default linters are being used$/) do
|
|
233
|
-
CukeLinter.reset_linters
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
And(/^a feature file model based on the following text:$/) do |text|
|
|
237
|
-
file_path = CukeLinter::FileHelper.create_file(directory: @root_test_directory, extension: '.feature', text: text)
|
|
238
|
-
|
|
239
|
-
@created_files ||= []
|
|
240
|
-
@created_files << file_path
|
|
241
|
-
|
|
242
|
-
@model = CukeModeler::FeatureFile.new(file_path)
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
Given(/^a feature file model named "([^"]*)"$/) do |file_path|
|
|
246
|
-
@model = CukeModeler::FeatureFile.new
|
|
247
|
-
|
|
248
|
-
@model.path = file_path
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
Given(/^a feature file model based on the file "([^"]*)" with the following text:$/) do |file_name, text|
|
|
252
|
-
file_path = CukeLinter::FileHelper.create_file(directory: @root_test_directory, extension: '.feature', text: text, name: file_name)
|
|
253
|
-
|
|
254
|
-
@created_files ||= []
|
|
255
|
-
@created_files << file_path
|
|
256
|
-
|
|
257
|
-
@model = CukeModeler::FeatureFile.new(file_path)
|
|
258
|
-
end
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
Then(/^a linting report will be made for all features$/) do
|
|
2
|
-
expect(@output).to match(/\d+ issues found/)
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
Then(/^the resulting output is the following:$/) do |text|
|
|
6
|
-
text.gsub!('<path_to>', @root_test_directory)
|
|
7
|
-
|
|
8
|
-
expect(@results.strip).to eq(text)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
Then(/^the resulting output will include the following:$/) do |text|
|
|
12
|
-
text.gsub!('<path_to>', @root_test_directory)
|
|
13
|
-
|
|
14
|
-
expect(@results.chomp).to include(text)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
Then(/^an error is reported:$/) do |table|
|
|
18
|
-
if @model.is_a?(CukeModeler::FeatureFile)
|
|
19
|
-
model_path = @model.path
|
|
20
|
-
model_source_line = ''
|
|
21
|
-
else
|
|
22
|
-
model_path = @model.get_ancestor(:feature_file).path
|
|
23
|
-
model_source_line = @model.source_line.to_s
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
table.hashes.each do |error_record|
|
|
27
|
-
expect(@results).to include({ linter: error_record['linter'],
|
|
28
|
-
problem: error_record['problem'],
|
|
29
|
-
location: error_record['location'].sub('<path_to_file>', model_path).sub('<model_line_number>', model_source_line) })
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
Then(/^the following problems are( not)? reported:$/) do |exclude, table|
|
|
34
|
-
assertion_method = exclude ? :to_not : :to
|
|
35
|
-
|
|
36
|
-
if @model.is_a?(CukeModeler::FeatureFile)
|
|
37
|
-
feature_file_model = @model
|
|
38
|
-
source_line = ''
|
|
39
|
-
else
|
|
40
|
-
feature_file_model = @model.get_ancestor(:feature_file)
|
|
41
|
-
source_line = @model.source_line.to_s
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
table.hashes.each do |error_record|
|
|
45
|
-
expect(@results).send(assertion_method, include({ linter: error_record['linter'],
|
|
46
|
-
problem: error_record['problem'],
|
|
47
|
-
location: error_record['location'].sub('<path_to_file>', feature_file_model.path).sub('<model_line_number>', source_line) }))
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
Then(/^the following linters are registered(?: by default)?$/) do |linter_names|
|
|
52
|
-
expect(CukeLinter.registered_linters.keys).to match_array(linter_names.raw.flatten)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
Then(/^an error is reported$/) do
|
|
56
|
-
expect(@results).to_not be_empty
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
Then(/^no error is reported$/) do
|
|
60
|
-
expect(@results).to be_empty
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
Then(/^the linter "([^"]*)" is no longer registered$/) do |linter_name|
|
|
64
|
-
expect(CukeLinter.registered_linters).to_not have_key(linter_name)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
Then(/^the following help is displayed:$/) do |text|
|
|
68
|
-
expect(@output.chomp).to eq(text)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
Then(/^the version of the tool is displayed:$/) do |text|
|
|
72
|
-
major_number, minor_number, patch_number = CukeLinter::VERSION.split('.')
|
|
73
|
-
text.sub!('<major>', major_number)
|
|
74
|
-
text.sub!('<minor>', minor_number)
|
|
75
|
-
text.sub!('<patch>', patch_number)
|
|
76
|
-
|
|
77
|
-
expect(@output.chomp).to eq(text)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
Then(/^the linting report will be output to "([^"]*)"$/) do |file_path|
|
|
81
|
-
file_path.gsub!('<path_to>', @root_test_directory)
|
|
82
|
-
|
|
83
|
-
expect(File.read(file_path)).to match(/\d+ issues found/)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
And(/^the file "([^"]*)" contains:$/) do |file_path, text|
|
|
87
|
-
file_path.gsub!('<path_to>', @root_test_directory)
|
|
88
|
-
|
|
89
|
-
expect(File.read(file_path)).to eq(text)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
Then(/^the exit code is "([^"]*)"$/) do |exit_code|
|
|
93
|
-
expect(@results[:status].exitstatus).to eq(exit_code.to_i)
|
|
94
|
-
end
|