cuke_linter 0.12.1 → 1.2.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 +40 -1
  3. data/README.md +12 -8
  4. data/cuke_linter.gemspec +26 -22
  5. data/exe/cuke_linter +4 -2
  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 +23 -15
  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 +101 -117
  37. data/.gitignore +0 -19
  38. data/.simplecov +0 -8
  39. data/.travis.yml +0 -33
  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 -464
  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
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- # JetBrains IDE metadata folders
14
- /.idea
15
-
16
- # Mac metadata directories
17
- .DS_Store
18
-
19
- Gemfile.lock
data/.simplecov DELETED
@@ -1,8 +0,0 @@
1
- SimpleCov.start do
2
- root __dir__
3
-
4
- add_filter '/testing/'
5
- add_filter '/environments/'
6
-
7
- merge_timeout 300
8
- end
@@ -1,33 +0,0 @@
1
- os:
2
- - linux
3
- - osx
4
- sudo: false
5
-
6
- # JRuby isn't working on the new default distribution
7
- dist: trusty
8
-
9
- language: ruby
10
- rvm:
11
- - 2.3.3
12
- - 2.4.0
13
- - 2.5.1
14
- - 2.6.0
15
- - jruby-9.1.7.0
16
-
17
- matrix:
18
- exclude:
19
- # Ruby 2.3.x is currently broken on TravisCI and is no longer a supported Ruby version, anyway.
20
- - rvm: 2.3.3
21
- os: osx
22
-
23
- gemfile:
24
- - testing/gemfiles/cuke_modeler1.gemfile
25
- - testing/gemfiles/cuke_modeler2.gemfile
26
-
27
- gemfile:
28
- - testing/gemfiles/cuke_modeler1.gemfile
29
- - testing/gemfiles/cuke_modeler2.gemfile
30
-
31
- before_install: gem install bundler -v 1.16.2
32
-
33
- script: bundle exec rake cuke_linter:ci_build
@@ -1,26 +0,0 @@
1
- # Development
2
-
3
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake cuke_linter:test_everything` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
4
-
5
-
6
- ## Contributing
7
-
8
- Bug reports and pull requests are welcome on GitHub at https://github.com/enkessler/cuke_linter.
9
-
10
- 1. Fork it
11
- 2. Create your feature branch **(off of the development branch)**
12
- `git checkout -b my-new-feature dev`
13
- 3. Commit your changes
14
- `git commit -am 'Add some feature'`
15
- 4. Push to the branch
16
- `git push origin my-new-feature`
17
- 5. Create new Pull Request
18
-
19
-
20
- ### Adding a new linter
21
-
22
- Some guidelines when adding a new linter
23
- * Inherit from the base linter class. It will handle almost all of the functional requirements of a linter.
24
- * Existing linters should provide decent examples of how to create new linters and how to test them. A copy/paste/tweak approach is perfectly valid.
25
- * Keep linters simple. Rather than have one linter that has different behaviors depending on context, create a different linter class for each context.
26
- * Keep things alphabetical. There are going to be lots of linters and things will be easier to find if lists of them in the code base (e.g. `require` statments, documentation, etc.) are in an intuitive order.
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in cuke_linter.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,63 +0,0 @@
1
- require 'rake'
2
- require 'racatt'
3
- require 'coveralls/rake/task'
4
- require 'rainbow'
5
-
6
- Rainbow.enabled = true
7
-
8
- namespace 'racatt' do
9
- Racatt.create_tasks
10
- end
11
-
12
- namespace 'cuke_linter' do
13
-
14
- desc 'Removes the current code coverage data'
15
- task :clear_coverage do
16
- code_coverage_directory = "#{__dir__}/coverage"
17
-
18
- FileUtils.remove_dir(code_coverage_directory, true)
19
- end
20
-
21
- desc 'Check documentation with RDoc'
22
- task :check_documentation do
23
- output = `rdoc lib -C`
24
- puts output
25
-
26
- if output =~ /100.00% documented/
27
- puts Rainbow('All code documented').green
28
- else
29
- raise Rainbow('Parts of the gem are undocumented').red
30
- end
31
- end
32
-
33
- desc 'Run all of the tests'
34
- task :test_everything => [:clear_coverage] do
35
- rspec_args = '--pattern "testing/rspec/spec/**/*_spec.rb" --force-color'
36
- cucumber_args = "testing/cucumber/features -r environments/cucumber_env.rb -f progress -t 'not @wip' --color"
37
-
38
- Rake::Task['racatt:test_everything'].invoke(rspec_args, cucumber_args)
39
- end
40
-
41
- # creates coveralls:push task
42
- Coveralls::RakeTask.new
43
-
44
- desc 'The task that CI will run. Do not run locally.'
45
- task :ci_build => ['cuke_linter:test_everything', 'coveralls:push']
46
-
47
- desc 'Check that things look good before trying to release'
48
- task :prerelease_check do
49
- begin
50
- Rake::Task['cuke_linter:test_everything'].invoke
51
- Rake::Task['cuke_linter:check_documentation'].invoke
52
- rescue => e
53
- puts Rainbow("-----------------------\nSomething isn't right!").red
54
- raise e
55
- end
56
-
57
- puts Rainbow("-----------------------\nAll is well. :)").green
58
- end
59
-
60
- end
61
-
62
-
63
- task :default => 'cuke_linter:test_everything'
@@ -1,43 +0,0 @@
1
- version: '1.0.{build}'
2
-
3
- environment:
4
- matrix:
5
- - RUBY_VERSION: 23
6
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
7
- - RUBY_VERSION: 23-x64
8
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
9
- - RUBY_VERSION: 24
10
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
11
- - RUBY_VERSION: 24-x64
12
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
13
- - RUBY_VERSION: 25
14
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
15
- - RUBY_VERSION: 25-x64
16
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler1.gemfile
17
-
18
- - RUBY_VERSION: 23
19
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler2.gemfile
20
- - RUBY_VERSION: 23-x64
21
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler2.gemfile
22
- - RUBY_VERSION: 24
23
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler2.gemfile
24
- - RUBY_VERSION: 24-x64
25
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler2.gemfile
26
- - RUBY_VERSION: 25
27
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler2.gemfile
28
- - RUBY_VERSION: 25-x64
29
- BUNDLE_GEMFILE: testing/gemfiles/cuke_modeler2.gemfile
30
-
31
- install:
32
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
33
- - bundle install
34
-
35
- build: off
36
-
37
- before_test:
38
- - ruby -v
39
- - gem -v
40
- - bundle -v
41
-
42
- test_script:
43
- - bundle exec rake cuke_linter:ci_build
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "cuke_linter"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -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
@@ -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,230 +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 features without a description") do
105
- @linter = CukeLinter::FeatureWithoutDescriptionLinter.new
106
- end
107
-
108
- Given(/^a linter for tests with no name$/) do
109
- @linter = CukeLinter::TestWithNoNameLinter.new
110
- end
111
-
112
- Given(/^a linter for tests that should use a background$/) do
113
- @linter = CukeLinter::TestShouldUseBackgroundLinter.new
114
- end
115
-
116
- Given(/^a linter for tests with a setup step after an action step$/) do
117
- @linter = CukeLinter::TestWithSetupStepAfterActionStepLinter.new
118
- end
119
-
120
- Given(/^a linter for tests with a setup step after a verification step$/) do
121
- @linter = CukeLinter::TestWithSetupStepAfterVerificationStepLinter.new
122
- end
123
-
124
- Given(/^a linter for tests with a setup step as the final step$/) do
125
- @linter = CukeLinter::TestWithSetupStepAsFinalStepLinter.new
126
- end
127
-
128
- Given(/^a linter for tests with an action step as the final step$/) do
129
- @linter = CukeLinter::TestWithActionStepAsFinalStepLinter.new
130
- end
131
-
132
- Given(/^a linter for elements with duplicate tags$/) do
133
- @linter = CukeLinter::ElementWithDuplicateTagsLinter.new
134
- end
135
-
136
- Given(/^a linter for elements with common tags$/) do
137
- @linter = CukeLinter::ElementWithCommonTagsLinter.new
138
- end
139
-
140
- Given(/^a linter for test steps with too many characters has been registered$/) do
141
- CukeLinter.register_linter(linter: CukeLinter::StepWithTooManyCharactersLinter.new, name: 'StepWithTooManyCharactersLinter')
142
- end
143
-
144
- Given(/^a linter for features with too many different tags has been registered$/) do
145
- CukeLinter.register_linter(linter: CukeLinter::FeatureWithTooManyDifferentTagsLinter.new, name: 'FeatureWithTooManyDifferentTagsLinter')
146
- end
147
-
148
- Given(/^the following configuration file(?: "([^"]*)")?:$/) do |file_name, text|
149
- file_name ||= '.cuke_linter'
150
-
151
- @configuration_file_path = CukeLinter::FileHelper.create_file(directory: @root_test_directory, name: file_name, extension: '', text: text)
152
- end
153
-
154
- Given(/^a linter "([^"]*)"$/) do |linter_class|
155
- @linter = CukeLinter.const_get(linter_class).new
156
- end
157
-
158
- Given(/^a linter registered as "([^"]*)"$/) do |linter_name|
159
- CukeLinter.register_linter(linter: CukeLinter::LinterFactory.generate_fake_linter(name: linter_name), name: linter_name)
160
- end
161
-
162
- Given(/^a directory "([^"]*)"$/) do |directory_name|
163
- @test_directory = CukeLinter::FileHelper.create_directory(directory: @root_test_directory, name: directory_name)
164
- end
165
-
166
- Given(/^no linters are currently registered$/) do
167
- CukeLinter.clear_registered_linters
168
- end
169
-
170
- Given(/^the following custom linter object:$/) do |code|
171
- code.sub!('<path_to>', @root_test_directory)
172
- code.sub!('<code_to_generate_a_new_linter_instance>', 'CukeLinter::LinterFactory.generate_fake_linter')
173
-
174
- if @working_directory
175
- Dir.chdir(@working_directory) do
176
- eval(code)
177
- end
178
- else
179
- eval(code)
180
- end
181
- end
182
-
183
- And(/^a model to lint$/) do
184
- # Any old model should be fine
185
- @model = CukeModeler::Feature.new
186
-
187
- fake_file_model = CukeModeler::FeatureFile.new
188
- fake_file_model.path = 'path_to_file'
189
-
190
- @model.parent_model = fake_file_model
191
- end
192
-
193
- Given(/^the following custom linter class:$/) do |code|
194
- eval(code)
195
- end
196
-
197
- Given(/^the following(?: feature)? file "([^"]*)":$/) do |file_path, text|
198
- path, extension = file_path.split('.')
199
-
200
- @created_files ||= []
201
- @created_files << CukeLinter::FileHelper.create_file(directory: @root_test_directory, name: path, extension: ".#{extension}", text: text)
202
- end
203
-
204
- Given(/^the default linters are being used$/) do
205
- CukeLinter.reset_linters
206
- end
207
-
208
- And(/^a feature file model based on the following text:$/) do |text|
209
- file_path = CukeLinter::FileHelper.create_file(directory: @root_test_directory, extension: '.feature', text: text)
210
-
211
- @created_files ||= []
212
- @created_files << file_path
213
-
214
- @model = CukeModeler::FeatureFile.new(file_path)
215
- end
216
-
217
- Given(/^a feature file model named "([^"]*)"$/) do |file_path|
218
- @model = CukeModeler::FeatureFile.new
219
-
220
- @model.path = file_path
221
- end
222
-
223
- Given(/^a feature file model based on the file "([^"]*)" with the following text:$/) do |file_name, text|
224
- file_path = CukeLinter::FileHelper.create_file(directory: @root_test_directory, extension: '.feature', text: text, name: file_name)
225
-
226
- @created_files ||= []
227
- @created_files << file_path
228
-
229
- @model = CukeModeler::FeatureFile.new(file_path)
230
- end