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
rubocop-rspec-2.31.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.30.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.29.2 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.29.1 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.29.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.28.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.27.1 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.27.0 lib/rubocop/rspec/language/node_pattern.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-2.26.1/lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.26.1 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.26.0 lib/rubocop/rspec/language/node_pattern.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.22.0/lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.25.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.24.1 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.24.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.23.2 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.23.1 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-2.23.0 lib/rubocop/rspec/language/node_pattern.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-2.22.0/lib/rubocop/rspec/language/node_pattern.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-2.22.0/lib/rubocop/rspec/language/node_pattern.rb