summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorVitali Tatarintev <vtatarintev@gitlab.com>2019-08-26 10:04:54 +0200
committerVitali Tatarintev <vtatarintev@gitlab.com>2019-08-28 08:43:47 +0200
commit99b27e69510e83006d4dd2e5ecc5c555409aa4a0 (patch)
tree80087416d0f94904e22f63bfbb39e6742b443b39 /rubocop
parentb61d26f496a2041d7124fd3280031deda3cf5a43 (diff)
downloadgitlab-ce-99b27e69510e83006d4dd2e5ecc5c555409aa4a0.tar.gz
Utilize Rubocop's Include for BeSuccessMatcher
Use Rubocop's Include instead of manually checking the matcher in controllers specs.
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/rspec/be_success_matcher.rb1
-rw-r--r--rubocop/spec_helpers.rb16
2 files changed, 0 insertions, 17 deletions
diff --git a/rubocop/cop/rspec/be_success_matcher.rb b/rubocop/cop/rspec/be_success_matcher.rb
index ca937a8ee9f..0b7d737f4e2 100644
--- a/rubocop/cop/rspec/be_success_matcher.rb
+++ b/rubocop/cop/rspec/be_success_matcher.rb
@@ -41,7 +41,6 @@ module RuboCop
end
def on_send(node)
- return unless in_controller_spec?(node)
return unless be_success_usage?(node)
add_offense(node, location: :expression, message: MESSAGE)
diff --git a/rubocop/spec_helpers.rb b/rubocop/spec_helpers.rb
index b38dc3f8cdb..ecd77c4351d 100644
--- a/rubocop/spec_helpers.rb
+++ b/rubocop/spec_helpers.rb
@@ -2,7 +2,6 @@ module RuboCop
module SpecHelpers
SPEC_HELPERS = %w[fast_spec_helper.rb rails_helper.rb spec_helper.rb].freeze
MIGRATION_SPEC_DIRECTORIES = ['spec/migrations', 'spec/lib/gitlab/background_migration'].freeze
- CONTROLLER_SPEC_DIRECTORIES = ['spec/controllers', 'spec/support/shared_examples/controllers'].freeze
# Returns true if the given node originated from the spec directory.
def in_spec?(node)
@@ -27,20 +26,5 @@ module RuboCop
in_spec?(node) &&
path.start_with?(*migration_directories)
end
-
- def controller_directories
- @controller_directories ||= CONTROLLER_SPEC_DIRECTORIES.map do |dir|
- pwd = RuboCop::PathUtil.pwd
- [File.join(pwd, dir), File.join(pwd, 'ee', dir)]
- end.flatten
- end
-
- # Returns true if the given node originated from a controller spec.
- def in_controller_spec?(node)
- path = node.location.expression.source_buffer.name
-
- in_spec?(node) &&
- path.start_with?(*controller_directories)
- end
end
end