Commit 69dbc5a5 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Remove Rubocop::SpecHelper file

parent 0fee9447
# frozen_string_literal: true
require_relative '../../spec_helpers'
module RuboCop
module Cop
module RSpec
......@@ -24,8 +22,6 @@ module RuboCop
# it { is_expected.to be_successful }
#
class BeSuccessMatcher < RuboCop::Cop::Cop
include SpecHelpers
MESSAGE = 'Do not use deprecated `success?` method, use `successful?` instead.'
def_node_search :expect_to_be_success?, <<~PATTERN
......
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
# Returns true if the given node originated from the spec directory.
def in_spec?(node)
path = node.location.expression.source_buffer.name
pwd = RuboCop::PathUtil.pwd
!SPEC_HELPERS.include?(File.basename(path)) &&
path.start_with?(File.join(pwd, 'spec'), File.join(pwd, 'ee', 'spec'))
end
def migration_directories
@migration_directories ||= MIGRATION_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 migration spec.
def in_migration_spec?(node)
path = node.location.expression.source_buffer.name
in_spec?(node) &&
path.start_with?(*migration_directories)
end
end
end
......@@ -2,9 +2,6 @@
require 'spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/rspec/be_success_matcher'
describe RuboCop::Cop::RSpec::BeSuccessMatcher do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment