Sha256: 9d938ed1e235791574ce21ca5519df47853a436cb2b2156226f6f3ee27eb010b

Contents?: true

Size: 1.44 KB

Versions: 26

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module RuboCop
  module RSpec
    module Language
      # Helper methods to detect RSpec DSL used with send and block
      # @deprecated Prefer using Node Pattern directly
      #   Use `'(block (send nil? #Example.all ...) ...)'` instead of
      #   `block_pattern('#Example.all')`
      module NodePattern
        # @deprecated Prefer using Node Pattern directly
        def send_pattern(string)
          deprecation_warning __method__
          "(send #rspec? #{string} ...)"
        end

        # @deprecated Prefer using Node Pattern directly
        def block_pattern(string)
          deprecation_warning __method__
          "(block #{send_pattern(string)} ...)"
        end

        # @deprecated Prefer using Node Pattern directly
        def numblock_pattern(string)
          deprecation_warning __method__
          "(numblock #{send_pattern(string)} ...)"
        end

        # @deprecated Prefer using Node Pattern directly
        def block_or_numblock_pattern(string)
          deprecation_warning __method__
          "{#{block_pattern(string)} #{numblock_pattern(string)}}"
        end

        private

        def deprecation_warning(method)
          # Only warn in derived extensions' specs
          return unless defined?(::RSpec)

          Kernel.warn <<~MESSAGE, uplevel: 2
            Usage of #{method} is deprecated. Use node pattern explicitly.
          MESSAGE
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 4 rubygems

Version Path
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.22.0/lib/rubocop/rspec/language/node_pattern.rb
fablicop-1.10.2 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-2.22.0/lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.22.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.21.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.20.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.19.0 lib/rubocop/rspec/language/node_pattern.rb