Merge pull request #11277 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-2.3.0
build(deps): bump rubocop-rspec from 2.2.0 to 2.3.0 in /Library/Homebrew
This commit is contained in:
		
						commit
						8e6ddb75d3
					
				@ -127,7 +127,7 @@ GEM
 | 
			
		||||
      activesupport (>= 4.2.0)
 | 
			
		||||
      rack (>= 1.1)
 | 
			
		||||
      rubocop (>= 0.90.0, < 2.0)
 | 
			
		||||
    rubocop-rspec (2.2.0)
 | 
			
		||||
    rubocop-rspec (2.3.0)
 | 
			
		||||
      rubocop (~> 1.0)
 | 
			
		||||
      rubocop-ast (>= 1.1.0)
 | 
			
		||||
    rubocop-sorbet (0.6.1)
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
# DO NOT EDIT MANUALLY
 | 
			
		||||
# This is an autogenerated file for types exported from the `rubocop-rspec` gem.
 | 
			
		||||
# Please instead update this file by running `tapioca sync`.
 | 
			
		||||
# Please instead update this file by running `bin/tapioca sync`.
 | 
			
		||||
 | 
			
		||||
# typed: true
 | 
			
		||||
 | 
			
		||||
@ -236,6 +236,7 @@ class RuboCop::Cop::RSpec::ContextWording < ::RuboCop::Cop::RSpec::Base
 | 
			
		||||
 | 
			
		||||
  def bad_prefix?(description); end
 | 
			
		||||
  def joined_prefixes; end
 | 
			
		||||
  def prefix_regex; end
 | 
			
		||||
  def prefixes; end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -432,11 +433,10 @@ class RuboCop::Cop::RSpec::ExampleLength < ::RuboCop::Cop::RSpec::Base
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def code_length(node); end
 | 
			
		||||
  def message(length); end
 | 
			
		||||
  def cop_label; end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
RuboCop::Cop::RSpec::ExampleLength::MSG = T.let(T.unsafe(nil), String)
 | 
			
		||||
RuboCop::Cop::RSpec::ExampleLength::LABEL = T.let(T.unsafe(nil), String)
 | 
			
		||||
 | 
			
		||||
class RuboCop::Cop::RSpec::ExampleWithoutDescription < ::RuboCop::Cop::RSpec::Base
 | 
			
		||||
  include(::RuboCop::Cop::ConfigurableEnforcedStyle)
 | 
			
		||||
@ -82,7 +82,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.13.0/lib"
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.0/lib"
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.2.0/lib"
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.3.0/lib"
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.1/lib"
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib"
 | 
			
		||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib"
 | 
			
		||||
 | 
			
		||||
@ -253,7 +253,9 @@ RSpec/ExampleLength:
 | 
			
		||||
  Description: Checks for long examples.
 | 
			
		||||
  Enabled: true
 | 
			
		||||
  Max: 5
 | 
			
		||||
  CountAsOne: []
 | 
			
		||||
  VersionAdded: '1.5'
 | 
			
		||||
  VersionChanged: '2.3'
 | 
			
		||||
  StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
 | 
			
		||||
 | 
			
		||||
RSpec/ExampleWithoutDescription:
 | 
			
		||||
@ -30,10 +30,12 @@ module RuboCop
 | 
			
		||||
        MSG_UNUSED_ARG = 'You should call `%<arg>s.call` ' \
 | 
			
		||||
                         'or `%<arg>s.run`.'
 | 
			
		||||
 | 
			
		||||
        # @!method hook(node)
 | 
			
		||||
        def_node_matcher :hook, <<-PATTERN
 | 
			
		||||
          (block (send nil? :around sym ?) (args $...) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method find_arg_usage(node)
 | 
			
		||||
        def_node_search :find_arg_usage, <<-PATTERN
 | 
			
		||||
          {(send $... {:call :run}) (send _ _ $...) (yield $...) (block-pass $...)}
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -22,6 +22,7 @@ module RuboCop
 | 
			
		||||
      class Be < Base
 | 
			
		||||
        MSG = "Don't use `be` without an argument."
 | 
			
		||||
 | 
			
		||||
        # @!method be_without_args(node)
 | 
			
		||||
        def_node_matcher :be_without_args, <<-PATTERN
 | 
			
		||||
          (send _ #Runners.all $(send nil? :be))
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -41,6 +41,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Prefer `be` over `eql`.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[to].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method eql_type_with_identity(node)
 | 
			
		||||
        def_node_matcher :eql_type_with_identity, <<-PATTERN
 | 
			
		||||
          (send _ :to $(send nil? :eql {true false int float sym nil_type?}))
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -31,6 +31,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        RESTRICT_ON_SEND = %i[before after].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method before_or_after_all(node)
 | 
			
		||||
        def_node_matcher :before_or_after_all, <<-PATTERN
 | 
			
		||||
          $(send _ {:before :after} (sym {:all :context}))
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -32,17 +32,20 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
          RESTRICT_ON_SEND = %i[expect].freeze
 | 
			
		||||
 | 
			
		||||
          # @!method expectation_set_on_current_path(node)
 | 
			
		||||
          def_node_matcher :expectation_set_on_current_path, <<-PATTERN
 | 
			
		||||
            (send nil? :expect (send {(send nil? :page) nil?} :current_path))
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # Supported matchers: eq(...) / match(/regexp/) / match('regexp')
 | 
			
		||||
          # @!method as_is_matcher(node)
 | 
			
		||||
          def_node_matcher :as_is_matcher, <<-PATTERN
 | 
			
		||||
            (send
 | 
			
		||||
              #expectation_set_on_current_path $#Runners.all
 | 
			
		||||
              ${(send nil? :eq ...) (send nil? :match (regexp ...))})
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # @!method regexp_str_matcher(node)
 | 
			
		||||
          def_node_matcher :regexp_str_matcher, <<-PATTERN
 | 
			
		||||
            (send
 | 
			
		||||
              #expectation_set_on_current_path $#Runners.all
 | 
			
		||||
@ -55,16 +55,19 @@ module RuboCop
 | 
			
		||||
            feature:    :describe
 | 
			
		||||
          }.freeze
 | 
			
		||||
 | 
			
		||||
          # @!method capybara_speak(node)
 | 
			
		||||
          def_node_matcher :capybara_speak, <<-PATTERN
 | 
			
		||||
            {#{MAP.keys.map(&:inspect).join(' ')}}
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # @!method spec?(node)
 | 
			
		||||
          def_node_matcher :spec?, <<-PATTERN
 | 
			
		||||
            (block
 | 
			
		||||
              (send #rspec? {:describe :feature} ...)
 | 
			
		||||
            ...)
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # @!method feature_method(node)
 | 
			
		||||
          def_node_matcher :feature_method, <<-PATTERN
 | 
			
		||||
            (block
 | 
			
		||||
              $(send #rspec? $#capybara_speak ...)
 | 
			
		||||
@ -46,10 +46,12 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
          RESTRICT_ON_SEND = CAPYBARA_MATCHER_METHODS
 | 
			
		||||
 | 
			
		||||
          # @!method visible_true?(node)
 | 
			
		||||
          def_node_matcher :visible_true?, <<~PATTERN
 | 
			
		||||
            (send nil? #capybara_matcher? ... (hash <$(pair (sym :visible) true) ...>))
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # @!method visible_false?(node)
 | 
			
		||||
          def_node_matcher :visible_false?, <<~PATTERN
 | 
			
		||||
            (send nil? #capybara_matcher? ... (hash <$(pair (sym :visible) false) ...>))
 | 
			
		||||
          PATTERN
 | 
			
		||||
@ -28,6 +28,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Use `describe` for testing methods.'
 | 
			
		||||
 | 
			
		||||
        # @!method context_method(node)
 | 
			
		||||
        def_node_matcher :context_method, <<-PATTERN
 | 
			
		||||
          (block (send #rspec? :context $(str #method_name?) ...) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -8,6 +8,7 @@ module RuboCop
 | 
			
		||||
      # The default list of prefixes is minimal. Users are encouraged to tailor
 | 
			
		||||
      # the configuration to meet project needs. Other acceptable prefixes may
 | 
			
		||||
      # include `if`, `unless`, `for`, `before`, `after`, or `during`.
 | 
			
		||||
      # They may consist of multiple words if desired.
 | 
			
		||||
      #
 | 
			
		||||
      # @see https://rspec.rubystyle.guide/#context-descriptions
 | 
			
		||||
      # @see http://www.betterspecs.org/#contexts
 | 
			
		||||
@ -37,6 +38,7 @@ module RuboCop
 | 
			
		||||
      class ContextWording < Base
 | 
			
		||||
        MSG = 'Start context description with %<prefixes>s.'
 | 
			
		||||
 | 
			
		||||
        # @!method context_wording(node)
 | 
			
		||||
        def_node_matcher :context_wording, <<-PATTERN
 | 
			
		||||
          (block (send #rspec? { :context :shared_context } $(str #bad_prefix?) ...) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -51,7 +53,7 @@ module RuboCop
 | 
			
		||||
        private
 | 
			
		||||
 | 
			
		||||
        def bad_prefix?(description)
 | 
			
		||||
          !prefixes.include?(description.split(/\b/).first)
 | 
			
		||||
          !prefix_regex.match?(description)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def joined_prefixes
 | 
			
		||||
@ -65,6 +67,10 @@ module RuboCop
 | 
			
		||||
        def prefixes
 | 
			
		||||
          cop_config['Prefixes'] || []
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def prefix_regex
 | 
			
		||||
          /^#{Regexp.union(prefixes)}\b/
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
@ -40,14 +40,17 @@ module RuboCop
 | 
			
		||||
        MSG = 'The first argument to describe should be ' \
 | 
			
		||||
              'the class or module being tested.'
 | 
			
		||||
 | 
			
		||||
        # @!method example_group_with_ignored_metadata?(node)
 | 
			
		||||
        def_node_matcher :example_group_with_ignored_metadata?, <<~PATTERN
 | 
			
		||||
          (send #rspec? :describe ... (hash <#ignored_metadata? ...>))
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method not_a_const_described(node)
 | 
			
		||||
        def_node_matcher :not_a_const_described, <<~PATTERN
 | 
			
		||||
          (send #rspec? :describe $[!const !#string_constant?] ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method sym_pair(node)
 | 
			
		||||
        def_node_matcher :sym_pair, <<~PATTERN
 | 
			
		||||
          (pair $sym $sym)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -22,6 +22,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'The second argument to describe should be the method ' \
 | 
			
		||||
              "being tested. '#instance' or '.class'."
 | 
			
		||||
 | 
			
		||||
        # @!method second_argument(node)
 | 
			
		||||
        def_node_matcher :second_argument, <<~PATTERN
 | 
			
		||||
          (block
 | 
			
		||||
            (send #rspec? :describe _first_argument $(str _) ...) ...
 | 
			
		||||
@ -21,6 +21,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Avoid describing symbols.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[describe].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method describe_symbol?(node)
 | 
			
		||||
        def_node_matcher :describe_symbol?, <<-PATTERN
 | 
			
		||||
          (send #rspec? :describe $sym ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -61,18 +61,23 @@ module RuboCop
 | 
			
		||||
        DESCRIBED_CLASS = 'described_class'
 | 
			
		||||
        MSG             = 'Use `%<replacement>s` instead of `%<src>s`.'
 | 
			
		||||
 | 
			
		||||
        # @!method common_instance_exec_closure?(node)
 | 
			
		||||
        def_node_matcher :common_instance_exec_closure?, <<-PATTERN
 | 
			
		||||
          (block (send (const nil? {:Class :Module :Struct}) :new ...) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method rspec_block?(node)
 | 
			
		||||
        def_node_matcher :rspec_block?, block_pattern('#ALL.all')
 | 
			
		||||
 | 
			
		||||
        # @!method scope_changing_syntax?(node)
 | 
			
		||||
        def_node_matcher :scope_changing_syntax?, '{def class module}'
 | 
			
		||||
 | 
			
		||||
        # @!method described_constant(node)
 | 
			
		||||
        def_node_matcher :described_constant, <<-PATTERN
 | 
			
		||||
          (block (send _ :describe $(const ...) ...) (args) $_)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method contains_described_class?(node)
 | 
			
		||||
        def_node_search :contains_described_class?, <<-PATTERN
 | 
			
		||||
          (send nil? :described_class)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -18,10 +18,11 @@ module RuboCop
 | 
			
		||||
      #     # ...
 | 
			
		||||
      #   end
 | 
			
		||||
      #
 | 
			
		||||
      # @see https://github.com/rubocop-hq/rubocop-rspec/issues/735
 | 
			
		||||
      # @see https://github.com/rubocop/rubocop-rspec/issues/735
 | 
			
		||||
      class DescribedClassModuleWrapping < Base
 | 
			
		||||
        MSG = 'Avoid opening modules and defining specs within them.'
 | 
			
		||||
 | 
			
		||||
        # @!method find_rspec_blocks(node)
 | 
			
		||||
        def_node_search :find_rspec_blocks, block_pattern('#ExampleGroups.all')
 | 
			
		||||
 | 
			
		||||
        def on_module(node)
 | 
			
		||||
@ -47,6 +47,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Prefer `%<prefer>s` over `%<current>s`.'
 | 
			
		||||
 | 
			
		||||
        # @!method rspec_method?(node)
 | 
			
		||||
        def_node_matcher :rspec_method?, send_pattern('#ALL.all')
 | 
			
		||||
 | 
			
		||||
        def on_send(node)
 | 
			
		||||
@ -28,6 +28,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Empty hook detected.'
 | 
			
		||||
 | 
			
		||||
        # @!method empty_hook?(node)
 | 
			
		||||
        def_node_matcher :empty_hook?, <<~PATTERN
 | 
			
		||||
          (block $#{send_pattern('#Hooks.all')} _ nil?)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -25,29 +25,43 @@ module RuboCop
 | 
			
		||||
      #     result = service.call
 | 
			
		||||
      #     expect(result).to be(true)
 | 
			
		||||
      #   end
 | 
			
		||||
      #
 | 
			
		||||
      # You can set literals you want to fold with `CountAsOne`.
 | 
			
		||||
      # Available are: 'array', 'hash', and 'heredoc'. Each literal
 | 
			
		||||
      # will be counted as one line regardless of its actual size.
 | 
			
		||||
      #
 | 
			
		||||
      # @example CountAsOne: ['array', 'heredoc']
 | 
			
		||||
      #
 | 
			
		||||
      #   it do
 | 
			
		||||
      #     array = [         # +1
 | 
			
		||||
      #       1,
 | 
			
		||||
      #       2
 | 
			
		||||
      #     ]
 | 
			
		||||
      #
 | 
			
		||||
      #     hash = {          # +3
 | 
			
		||||
      #       key: 'value'
 | 
			
		||||
      #     }
 | 
			
		||||
      #
 | 
			
		||||
      #     msg = <<~HEREDOC  # +1
 | 
			
		||||
      #       Heredoc
 | 
			
		||||
      #       content.
 | 
			
		||||
      #     HEREDOC
 | 
			
		||||
      #   end                 # 5 points
 | 
			
		||||
      class ExampleLength < Base
 | 
			
		||||
        include CodeLength
 | 
			
		||||
 | 
			
		||||
        MSG = 'Example has too many lines [%<total>d/%<max>d].'
 | 
			
		||||
        LABEL = 'Example'
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
          return unless example?(node)
 | 
			
		||||
 | 
			
		||||
          length = code_length(node)
 | 
			
		||||
 | 
			
		||||
          return unless length > max_length
 | 
			
		||||
 | 
			
		||||
          add_offense(node, message: message(length))
 | 
			
		||||
          check_code_length(node)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        private
 | 
			
		||||
 | 
			
		||||
        def code_length(node)
 | 
			
		||||
          node.source.lines[1..-2].count { |line| !irrelevant_line(line) }
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def message(length)
 | 
			
		||||
          format(MSG, total: length, max: max_length)
 | 
			
		||||
        def cop_label
 | 
			
		||||
          LABEL
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
@ -54,6 +54,7 @@ module RuboCop
 | 
			
		||||
                               'have auto-generated description.'
 | 
			
		||||
        MSG_ADD_DESCRIPTION  = 'Add a description.'
 | 
			
		||||
 | 
			
		||||
        # @!method example_description(node)
 | 
			
		||||
        def_node_matcher :example_description, '(send nil? _ $(str $_))'
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
@ -38,6 +38,7 @@ module RuboCop
 | 
			
		||||
        SHOULD_PREFIX = /\Ashould(?:n't)?\b/i.freeze
 | 
			
		||||
        IT_PREFIX     = /\Ait /i.freeze
 | 
			
		||||
 | 
			
		||||
        # @!method it_description(node)
 | 
			
		||||
        def_node_matcher :it_description, <<-PATTERN
 | 
			
		||||
          (block (send _ :it ${
 | 
			
		||||
            (str $_)
 | 
			
		||||
@ -45,6 +45,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        SUPPORTED_MATCHERS = %i[eq eql equal be].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method expect_literal(node)
 | 
			
		||||
        def_node_matcher :expect_literal, <<~PATTERN
 | 
			
		||||
          (send
 | 
			
		||||
            (send nil? :expect $#literal?)
 | 
			
		||||
@ -37,10 +37,12 @@ module RuboCop
 | 
			
		||||
        MSG_CALL = 'Prefer `change { %<obj>s.%<attr>s }`.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[change].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method expect_change_with_arguments(node)
 | 
			
		||||
        def_node_matcher :expect_change_with_arguments, <<-PATTERN
 | 
			
		||||
          (send nil? :change ({const send} nil? $_) (sym $_))
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method expect_change_with_block(node)
 | 
			
		||||
        def_node_matcher :expect_change_with_block, <<-PATTERN
 | 
			
		||||
          (block
 | 
			
		||||
            (send nil? :change)
 | 
			
		||||
@ -23,6 +23,7 @@ module RuboCop
 | 
			
		||||
      class ExpectInHook < Base
 | 
			
		||||
        MSG = 'Do not use `%<expect>s` in `%<hook>s` hook'
 | 
			
		||||
 | 
			
		||||
        # @!method expectation(node)
 | 
			
		||||
        def_node_search :expectation, send_pattern('#Expectations.all')
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
@ -29,10 +29,12 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
          MSG = 'Use a block to declare attribute values.'
 | 
			
		||||
 | 
			
		||||
          # @!method value_matcher(node)
 | 
			
		||||
          def_node_matcher :value_matcher, <<-PATTERN
 | 
			
		||||
            (send _ !#reserved_method? $...)
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # @!method factory_attributes(node)
 | 
			
		||||
          def_node_matcher :factory_attributes, <<-PATTERN
 | 
			
		||||
            (block (send _ #attribute_defining_method? ...) _ { (begin $...) $(send ...) } )
 | 
			
		||||
          PATTERN
 | 
			
		||||
@ -79,6 +81,7 @@ module RuboCop
 | 
			
		||||
            value_matcher(attribute).to_a.all?(&:block_pass_type?)
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          # @!method association?(node)
 | 
			
		||||
          def_node_matcher :association?, '(hash <(pair (sym :factory) _) ...>)'
 | 
			
		||||
 | 
			
		||||
          def autocorrect_replacing_parens(corrector, node)
 | 
			
		||||
@ -32,6 +32,7 @@ module RuboCop
 | 
			
		||||
          MSG_N_TIMES = 'Prefer %<number>s.times.'
 | 
			
		||||
          RESTRICT_ON_SEND = %i[create_list].freeze
 | 
			
		||||
 | 
			
		||||
          # @!method n_times_block_without_arg?(node)
 | 
			
		||||
          def_node_matcher :n_times_block_without_arg?, <<-PATTERN
 | 
			
		||||
            (block
 | 
			
		||||
              (send (int _) :times)
 | 
			
		||||
@ -40,10 +41,12 @@ module RuboCop
 | 
			
		||||
            )
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # @!method factory_call(node)
 | 
			
		||||
          def_node_matcher :factory_call, <<-PATTERN
 | 
			
		||||
            (send ${(const nil? {:FactoryGirl :FactoryBot}) nil?} :create (sym $_) $...)
 | 
			
		||||
          PATTERN
 | 
			
		||||
 | 
			
		||||
          # @!method factory_list_call(node)
 | 
			
		||||
          def_node_matcher :factory_list_call, <<-PATTERN
 | 
			
		||||
            (send {(const nil? {:FactoryGirl :FactoryBot}) nil?} :create_list (sym _) (int $_) ...)
 | 
			
		||||
          PATTERN
 | 
			
		||||
@ -27,6 +27,7 @@ module RuboCop
 | 
			
		||||
          ALLOWED_CONSTANTS = %w[Hash OpenStruct].freeze
 | 
			
		||||
          RESTRICT_ON_SEND = %i[factory].freeze
 | 
			
		||||
 | 
			
		||||
          # @!method class_name(node)
 | 
			
		||||
          def_node_matcher :class_name, <<~PATTERN
 | 
			
		||||
            (send _ :factory _ (hash <(pair (sym :class) $(const ...)) ...>))
 | 
			
		||||
          PATTERN
 | 
			
		||||
@ -61,12 +61,14 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Spec path should end with `%<suffix>s`.'
 | 
			
		||||
 | 
			
		||||
        # @!method const_described(node)
 | 
			
		||||
        def_node_matcher :const_described, <<~PATTERN
 | 
			
		||||
          (block
 | 
			
		||||
            $(send #rspec? _example_group $(const ...) $...) ...
 | 
			
		||||
          )
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method routing_metadata?(node)
 | 
			
		||||
        def_node_search :routing_metadata?, '(pair (sym :type) (sym :routing))'
 | 
			
		||||
 | 
			
		||||
        def on_top_level_example_group(node)
 | 
			
		||||
@ -25,6 +25,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Focused spec found.'
 | 
			
		||||
 | 
			
		||||
        # @!method focusable_selector?(node)
 | 
			
		||||
        def_node_matcher :focusable_selector?, <<-PATTERN
 | 
			
		||||
          {
 | 
			
		||||
            #ExampleGroups.regular
 | 
			
		||||
@ -35,11 +36,13 @@ module RuboCop
 | 
			
		||||
          }
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method metadata(node)
 | 
			
		||||
        def_node_matcher :metadata, <<-PATTERN
 | 
			
		||||
          {(send #rspec? #focusable_selector? <$(sym :focus) ...>)
 | 
			
		||||
           (send #rspec? #focusable_selector? ... (hash <$(pair (sym :focus) true) ...>))}
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method focused_block?(node)
 | 
			
		||||
        def_node_matcher :focused_block?,
 | 
			
		||||
                         send_pattern(<<~PATTERN)
 | 
			
		||||
                           {#ExampleGroups.focused #Examples.focused}
 | 
			
		||||
@ -64,10 +64,12 @@ module RuboCop
 | 
			
		||||
        IMPLICIT_MSG = 'Omit the default `%<scope>p` argument for RSpec hooks.'
 | 
			
		||||
        EXPLICIT_MSG = 'Use `%<scope>p` for RSpec hooks.'
 | 
			
		||||
 | 
			
		||||
        # @!method scoped_hook(node)
 | 
			
		||||
        def_node_matcher :scoped_hook, <<-PATTERN
 | 
			
		||||
          (block $(send _ #Hooks.all (sym ${:each :example})) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method unscoped_hook(node)
 | 
			
		||||
        def_node_matcher :unscoped_hook, '(block $(send _ #Hooks.all) ...)'
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
@ -28,6 +28,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Move `%<hook>s` above the examples in the group.'
 | 
			
		||||
 | 
			
		||||
        # @!method example_or_group?(node)
 | 
			
		||||
        def_node_matcher :example_or_group?, <<-PATTERN
 | 
			
		||||
          {
 | 
			
		||||
            #{block_pattern('{#ExampleGroups.all #Examples.all}')}
 | 
			
		||||
@ -20,6 +20,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Avoid implicit block expectations.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[is_expected should should_not].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method lambda?(node)
 | 
			
		||||
        def_node_matcher :lambda?, <<-PATTERN
 | 
			
		||||
          {
 | 
			
		||||
            (send (const nil? :Proc) :new)
 | 
			
		||||
@ -27,8 +28,10 @@ module RuboCop
 | 
			
		||||
          }
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method lambda_subject?(node)
 | 
			
		||||
        def_node_matcher :lambda_subject?, '(block #lambda? ...)'
 | 
			
		||||
 | 
			
		||||
        # @!method implicit_expect(node)
 | 
			
		||||
        def_node_matcher :implicit_expect, <<-PATTERN
 | 
			
		||||
          $(send nil? {:is_expected :should :should_not} ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -30,6 +30,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Prefer `%<good>s` over `%<bad>s`.'
 | 
			
		||||
 | 
			
		||||
        # @!method implicit_expect(node)
 | 
			
		||||
        def_node_matcher :implicit_expect, <<-PATTERN
 | 
			
		||||
          {
 | 
			
		||||
            (send nil? ${:should :should_not} ...)
 | 
			
		||||
@ -33,6 +33,7 @@ module RuboCop
 | 
			
		||||
        MSG = "Don't use implicit subject."
 | 
			
		||||
        RESTRICT_ON_SEND = %i[is_expected should should_not].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method implicit_subject?(node)
 | 
			
		||||
        def_node_matcher :implicit_subject?, <<-PATTERN
 | 
			
		||||
          (send nil? {:should :should_not :is_expected} ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -24,6 +24,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Use `instance_spy` when you check your double ' \
 | 
			
		||||
              'with `have_received`.'
 | 
			
		||||
 | 
			
		||||
        # @!method null_double(node)
 | 
			
		||||
        def_node_search :null_double, <<-PATTERN
 | 
			
		||||
          (lvasgn $_
 | 
			
		||||
            (send
 | 
			
		||||
@ -31,6 +32,7 @@ module RuboCop
 | 
			
		||||
                ...) :as_null_object))
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method have_received_usage(node)
 | 
			
		||||
        def_node_search :have_received_usage, <<-PATTERN
 | 
			
		||||
          (send
 | 
			
		||||
            (send nil? :expect
 | 
			
		||||
@ -52,10 +52,12 @@ module RuboCop
 | 
			
		||||
        MSG = 'Avoid instance variables – use let, ' \
 | 
			
		||||
              'a method call, or a local variable (if possible).'
 | 
			
		||||
 | 
			
		||||
        # @!method dynamic_class?(node)
 | 
			
		||||
        def_node_matcher :dynamic_class?, <<-PATTERN
 | 
			
		||||
          (block (send (const nil? :Class) :new ...) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method custom_matcher?(node)
 | 
			
		||||
        def_node_matcher :custom_matcher?, <<-PATTERN
 | 
			
		||||
          (block {
 | 
			
		||||
            (send nil? :matcher sym)
 | 
			
		||||
@ -63,8 +65,10 @@ module RuboCop
 | 
			
		||||
          } ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method ivar_usage(node)
 | 
			
		||||
        def_node_search :ivar_usage, '$(ivar $_)'
 | 
			
		||||
 | 
			
		||||
        # @!method ivar_assigned?(node)
 | 
			
		||||
        def_node_search :ivar_assigned?, '(ivasgn % ...)'
 | 
			
		||||
 | 
			
		||||
        def on_top_level_group(node)
 | 
			
		||||
@ -26,6 +26,7 @@ module RuboCop
 | 
			
		||||
              'examples in a nested context.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[it_behaves_like it_should_behave_like].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method example_inclusion_offense(node)
 | 
			
		||||
        def_node_matcher :example_inclusion_offense, '(send _ % ...)'
 | 
			
		||||
 | 
			
		||||
        def on_send(node)
 | 
			
		||||
@ -19,6 +19,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Prefer using the `all` matcher instead ' \
 | 
			
		||||
              'of iterating over an array.'
 | 
			
		||||
 | 
			
		||||
        # @!method each?(node)
 | 
			
		||||
        def_node_matcher :each?, <<-PATTERN
 | 
			
		||||
          (block
 | 
			
		||||
            (send ... :each)
 | 
			
		||||
@ -27,6 +28,7 @@ module RuboCop
 | 
			
		||||
          )
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method expectation?(node)
 | 
			
		||||
        def_node_matcher :expectation?, <<-PATTERN
 | 
			
		||||
          (send (send nil? :expect (lvar %)) :to ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -35,6 +35,7 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Move `let` before the examples in the group.'
 | 
			
		||||
 | 
			
		||||
        # @!method example_or_group?(node)
 | 
			
		||||
        def_node_matcher :example_or_group?, <<-PATTERN
 | 
			
		||||
          {
 | 
			
		||||
            #{block_pattern('{#ExampleGroups.all #Examples.all}')}
 | 
			
		||||
@ -28,6 +28,7 @@ module RuboCop
 | 
			
		||||
      class LetSetup < Base
 | 
			
		||||
        MSG = 'Do not use `let!` to setup objects not referenced in tests.'
 | 
			
		||||
 | 
			
		||||
        # @!method example_or_shared_group_or_including?(node)
 | 
			
		||||
        def_node_matcher :example_or_shared_group_or_including?,
 | 
			
		||||
                         block_pattern(<<~PATTERN)
 | 
			
		||||
                           {
 | 
			
		||||
@ -37,6 +38,7 @@ module RuboCop
 | 
			
		||||
                           }
 | 
			
		||||
                         PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method let_bang(node)
 | 
			
		||||
        def_node_matcher :let_bang, <<-PATTERN
 | 
			
		||||
          {
 | 
			
		||||
            (block $(send nil? :let! {(sym $_) (str $_)}) ...)
 | 
			
		||||
@ -44,6 +46,7 @@ module RuboCop
 | 
			
		||||
          }
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method method_called?(node)
 | 
			
		||||
        def_node_search :method_called?, '(send nil? %)'
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
@ -32,10 +32,12 @@ module RuboCop
 | 
			
		||||
        SUPPORTED_STYLES = %w[allow expect].freeze
 | 
			
		||||
        RESTRICT_ON_SEND = %i[to].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method message_expectation(node)
 | 
			
		||||
        def_node_matcher :message_expectation, <<-PATTERN
 | 
			
		||||
          (send $(send nil? {:expect :allow} ...) :to #receive_message?)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method receive_message?(node)
 | 
			
		||||
        def_node_search :receive_message?, '(send nil? :receive ...)'
 | 
			
		||||
 | 
			
		||||
        def on_send(node)
 | 
			
		||||
@ -35,10 +35,12 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        SUPPORTED_STYLES = %w[have_received receive].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method message_expectation(node)
 | 
			
		||||
        def_node_matcher :message_expectation, %(
 | 
			
		||||
          (send (send nil? :expect $_) #Runners.all ...)
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        # @!method receive_message(node)
 | 
			
		||||
        def_node_search :receive_message, %(
 | 
			
		||||
          $(send nil? {:receive :have_received} ...)
 | 
			
		||||
        )
 | 
			
		||||
@ -10,6 +10,7 @@ module RuboCop
 | 
			
		||||
        Subjects = RuboCop::RSpec::Language::Subjects
 | 
			
		||||
        Helpers = RuboCop::RSpec::Language::Helpers
 | 
			
		||||
 | 
			
		||||
        # @!method variable_definition?(node)
 | 
			
		||||
        def_node_matcher :variable_definition?, <<~PATTERN
 | 
			
		||||
          (send nil? {#Subjects.all #Helpers.all}
 | 
			
		||||
            $({sym str dsym dstr} ...) ...)
 | 
			
		||||
@ -53,6 +53,7 @@ module RuboCop
 | 
			
		||||
        ANYTHING = ->(_node) { true }
 | 
			
		||||
        TRUE = ->(node) { node.true_type? }
 | 
			
		||||
 | 
			
		||||
        # @!method aggregate_failures?(node)
 | 
			
		||||
        def_node_matcher :aggregate_failures?, <<-PATTERN
 | 
			
		||||
          (block {
 | 
			
		||||
              (send _ _ <(sym :aggregate_failures) ...>)
 | 
			
		||||
@ -60,7 +61,9 @@ module RuboCop
 | 
			
		||||
            } ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method expect?(node)
 | 
			
		||||
        def_node_matcher :expect?, send_pattern('#Expectations.all')
 | 
			
		||||
        # @!method aggregate_failures_block?(node)
 | 
			
		||||
        def_node_matcher :aggregate_failures_block?, <<-PATTERN
 | 
			
		||||
          (block (send nil? :aggregate_failures ...) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -44,12 +44,15 @@ module RuboCop
 | 
			
		||||
      class NamedSubject < Base
 | 
			
		||||
        MSG = 'Name your test subject if you need to reference it explicitly.'
 | 
			
		||||
 | 
			
		||||
        # @!method example_or_hook_block?(node)
 | 
			
		||||
        def_node_matcher :example_or_hook_block?,
 | 
			
		||||
                         block_pattern('{#Examples.all #Hooks.all}')
 | 
			
		||||
 | 
			
		||||
        # @!method shared_example?(node)
 | 
			
		||||
        def_node_matcher :shared_example?,
 | 
			
		||||
                         block_pattern('#SharedGroups.examples')
 | 
			
		||||
 | 
			
		||||
        # @!method subject_usage(node)
 | 
			
		||||
        def_node_search :subject_usage, '$(send nil? :subject)'
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
@ -22,6 +22,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Prefer `%<replacement>s` over `%<original>s`.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[not_to to_not].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method not_to_not_offense(node)
 | 
			
		||||
        def_node_matcher :not_to_not_offense, '(send _ % ...)'
 | 
			
		||||
 | 
			
		||||
        def on_send(node)
 | 
			
		||||
@ -24,8 +24,10 @@ module RuboCop
 | 
			
		||||
      class OverwritingSetup < Base
 | 
			
		||||
        MSG = '`%<name>s` is already defined.'
 | 
			
		||||
 | 
			
		||||
        # @!method setup?(node)
 | 
			
		||||
        def_node_matcher :setup?, block_pattern('{#Helpers.all #Subjects.all}')
 | 
			
		||||
 | 
			
		||||
        # @!method first_argument_name(node)
 | 
			
		||||
        def_node_matcher :first_argument_name, '(send _ _ ({str sym} $_))'
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
@ -34,11 +34,13 @@ module RuboCop
 | 
			
		||||
      class Pending < Base
 | 
			
		||||
        MSG = 'Pending spec found.'
 | 
			
		||||
 | 
			
		||||
        # @!method skippable?(node)
 | 
			
		||||
        def_node_matcher :skippable?,
 | 
			
		||||
                         send_pattern(<<~PATTERN)
 | 
			
		||||
                           {#ExampleGroups.regular #Examples.regular}
 | 
			
		||||
                         PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method skipped_in_metadata?(node)
 | 
			
		||||
        def_node_matcher :skipped_in_metadata?, <<-PATTERN
 | 
			
		||||
          {
 | 
			
		||||
            (send _ _ <#skip_or_pending? ...>)
 | 
			
		||||
@ -46,8 +48,10 @@ module RuboCop
 | 
			
		||||
          }
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method skip_or_pending?(node)
 | 
			
		||||
        def_node_matcher :skip_or_pending?, '{(sym :skip) (sym :pending)}'
 | 
			
		||||
 | 
			
		||||
        # @!method pending_block?(node)
 | 
			
		||||
        def_node_matcher :pending_block?,
 | 
			
		||||
                         send_pattern(<<~PATTERN)
 | 
			
		||||
                           {
 | 
			
		||||
@ -25,6 +25,7 @@ module RuboCop
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        # @!method predicate_in_actual?(node)
 | 
			
		||||
        def_node_matcher :predicate_in_actual?, <<-PATTERN
 | 
			
		||||
          (send
 | 
			
		||||
            (send nil? :expect {
 | 
			
		||||
@ -34,10 +35,12 @@ module RuboCop
 | 
			
		||||
            $#boolean_matcher?)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method be_bool?(node)
 | 
			
		||||
        def_node_matcher :be_bool?, <<-PATTERN
 | 
			
		||||
          (send nil? {:be :eq :eql :equal} {true false})
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method be_boolthy?(node)
 | 
			
		||||
        def_node_matcher :be_boolthy?, <<-PATTERN
 | 
			
		||||
          (send nil? {:be_truthy :be_falsey :be_falsy :a_truthy_value :a_falsey_value :a_falsy_value})
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -152,6 +155,7 @@ module RuboCop
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        # @!method predicate_matcher?(node)
 | 
			
		||||
        def_node_matcher :predicate_matcher?, <<-PATTERN
 | 
			
		||||
          (send
 | 
			
		||||
            (send nil? :expect $!nil?)
 | 
			
		||||
@ -160,6 +164,7 @@ module RuboCop
 | 
			
		||||
              (block $(send nil? #predicate_matcher_name? ...) ...)})
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method predicate_matcher_block?(node)
 | 
			
		||||
        def_node_matcher :predicate_matcher_block?, <<-PATTERN
 | 
			
		||||
          (block
 | 
			
		||||
            (send
 | 
			
		||||
@ -35,6 +35,7 @@ module RuboCop
 | 
			
		||||
          include ConfigurableEnforcedStyle
 | 
			
		||||
          RESTRICT_ON_SEND = %i[have_http_status].freeze
 | 
			
		||||
 | 
			
		||||
          # @!method http_status(node)
 | 
			
		||||
          def_node_matcher :http_status, <<-PATTERN
 | 
			
		||||
            (send nil? :have_http_status ${int sym})
 | 
			
		||||
          PATTERN
 | 
			
		||||
@ -30,10 +30,12 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        RESTRICT_ON_SEND = %i[times].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method receive_counts(node)
 | 
			
		||||
        def_node_matcher :receive_counts, <<-PATTERN
 | 
			
		||||
          (send $(send _ {:exactly :at_least :at_most} (int {1 2})) :times)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method stub?(node)
 | 
			
		||||
        def_node_search :stub?, '(send nil? :receive ...)'
 | 
			
		||||
 | 
			
		||||
        def on_send(node)
 | 
			
		||||
@ -18,6 +18,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Use `not_to receive` instead of `never`.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[never].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method method_on_stub?(node)
 | 
			
		||||
        def_node_search :method_on_stub?, '(send nil? :receive ...)'
 | 
			
		||||
 | 
			
		||||
        def on_send(node)
 | 
			
		||||
@ -46,16 +46,23 @@ module RuboCop
 | 
			
		||||
      class RepeatedExampleGroupBody < Base
 | 
			
		||||
        MSG = 'Repeated %<group>s block body on line(s) %<loc>s'
 | 
			
		||||
 | 
			
		||||
        # @!method several_example_groups?(node)
 | 
			
		||||
        def_node_matcher :several_example_groups?, <<-PATTERN
 | 
			
		||||
          (begin <#example_group_with_body? #example_group_with_body? ...>)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method metadata(node)
 | 
			
		||||
        def_node_matcher :metadata, '(block (send _ _ _ $...) ...)'
 | 
			
		||||
 | 
			
		||||
        # @!method body(node)
 | 
			
		||||
        def_node_matcher :body, '(block _ args $...)'
 | 
			
		||||
 | 
			
		||||
        # @!method const_arg(node)
 | 
			
		||||
        def_node_matcher :const_arg, '(block (send _ _ $const ...) ...)'
 | 
			
		||||
 | 
			
		||||
        # @!method skip_or_pending?(node)
 | 
			
		||||
        def_node_matcher :skip_or_pending?, <<-PATTERN
 | 
			
		||||
          (block <(send nil? {:skip :pending}) ...>)
 | 
			
		||||
          (block <(send nil? {:skip :pending} ...) ...>)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        def on_begin(node)
 | 
			
		||||
@ -46,18 +46,22 @@ module RuboCop
 | 
			
		||||
      class RepeatedExampleGroupDescription < Base
 | 
			
		||||
        MSG = 'Repeated %<group>s block description on line(s) %<loc>s'
 | 
			
		||||
 | 
			
		||||
        # @!method several_example_groups?(node)
 | 
			
		||||
        def_node_matcher :several_example_groups?, <<-PATTERN
 | 
			
		||||
          (begin <#example_group? #example_group? ...>)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method doc_string_and_metadata(node)
 | 
			
		||||
        def_node_matcher :doc_string_and_metadata, <<-PATTERN
 | 
			
		||||
          (block (send _ _ $_ $...) ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method skip_or_pending?(node)
 | 
			
		||||
        def_node_matcher :skip_or_pending?, <<-PATTERN
 | 
			
		||||
          (block <(send nil? {:skip :pending}) ...>)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method empty_description?(node)
 | 
			
		||||
        def_node_matcher :empty_description?, '(block (send _ _) ...)'
 | 
			
		||||
 | 
			
		||||
        def on_begin(node)
 | 
			
		||||
@ -50,13 +50,16 @@ module RuboCop
 | 
			
		||||
        MSG = 'Repeated include of shared_examples %<name>s ' \
 | 
			
		||||
          'on line(s) %<repeat>s'
 | 
			
		||||
 | 
			
		||||
        # @!method several_include_examples?(node)
 | 
			
		||||
        def_node_matcher :several_include_examples?, <<-PATTERN
 | 
			
		||||
          (begin <#include_examples? #include_examples? ...>)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method include_examples?(node)
 | 
			
		||||
        def_node_matcher :include_examples?,
 | 
			
		||||
                         send_pattern('#Includes.examples')
 | 
			
		||||
 | 
			
		||||
        # @!method shared_examples_name(node)
 | 
			
		||||
        def_node_matcher :shared_examples_name, <<-PATTERN
 | 
			
		||||
          (send _ #Includes.examples $_ ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -41,8 +41,13 @@ module RuboCop
 | 
			
		||||
        MSG_BLOCK = 'Use block for static values.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[and_return].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method contains_stub?(node)
 | 
			
		||||
        def_node_search :contains_stub?, '(send nil? :receive (...))'
 | 
			
		||||
 | 
			
		||||
        # @!method stub_with_block?(node)
 | 
			
		||||
        def_node_matcher :stub_with_block?, '(block #contains_stub? ...)'
 | 
			
		||||
 | 
			
		||||
        # @!method and_return_value(node)
 | 
			
		||||
        def_node_search :and_return_value, <<-PATTERN
 | 
			
		||||
          $(send _ :and_return $(...))
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -56,9 +56,11 @@ module RuboCop
 | 
			
		||||
        MSG_EXAMPLES = "Use `shared_examples` when you don't define context."
 | 
			
		||||
        MSG_CONTEXT  = "Use `shared_context` when you don't define examples."
 | 
			
		||||
 | 
			
		||||
        # @!method examples?(node)
 | 
			
		||||
        def_node_search :examples?,
 | 
			
		||||
                        send_pattern('{#Includes.examples #Examples.all}')
 | 
			
		||||
 | 
			
		||||
        # @!method context?(node)
 | 
			
		||||
        def_node_search :context?, <<-PATTERN
 | 
			
		||||
          (
 | 
			
		||||
            send #rspec? {
 | 
			
		||||
@ -70,8 +72,10 @@ module RuboCop
 | 
			
		||||
          )
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method shared_context(node)
 | 
			
		||||
        def_node_matcher :shared_context,
 | 
			
		||||
                         block_pattern('#SharedGroups.context')
 | 
			
		||||
        # @!method shared_example(node)
 | 
			
		||||
        def_node_matcher :shared_example,
 | 
			
		||||
                         block_pattern('#SharedGroups.examples')
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,7 @@ module RuboCop
 | 
			
		||||
      class SharedExamples < Base
 | 
			
		||||
        extend AutoCorrector
 | 
			
		||||
 | 
			
		||||
        # @!method shared_examples(node)
 | 
			
		||||
        def_node_matcher :shared_examples,
 | 
			
		||||
                         send_pattern(
 | 
			
		||||
                           '{#SharedGroups.all #Includes.all}'
 | 
			
		||||
@ -23,10 +23,12 @@ module RuboCop
 | 
			
		||||
              '`%<called>s` with a single argument.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method message_chain(node)
 | 
			
		||||
        def_node_matcher :message_chain, <<-PATTERN
 | 
			
		||||
          (send _ {:receive_message_chain :stub_chain} $_)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method single_key_hash?(node)
 | 
			
		||||
        def_node_matcher :single_key_hash?, '(hash pair)'
 | 
			
		||||
 | 
			
		||||
        def on_send(node)
 | 
			
		||||
@ -39,6 +39,7 @@ module RuboCop
 | 
			
		||||
          }
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method configured_response?(node)
 | 
			
		||||
        def_node_matcher :configured_response?, <<~PATTERN
 | 
			
		||||
          { :and_return :and_raise :and_throw :and_yield
 | 
			
		||||
            :and_call_original :and_wrap_original }
 | 
			
		||||
@ -81,6 +81,7 @@ module RuboCop
 | 
			
		||||
          )
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method message_expectation_matcher?(node)
 | 
			
		||||
        def_node_search :message_expectation_matcher?, <<-PATTERN
 | 
			
		||||
          (send nil? {
 | 
			
		||||
            :receive :receive_messages :receive_message_chain :have_received
 | 
			
		||||
@ -34,6 +34,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Specify the exception being captured'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[to].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method empty_raise_error_or_exception(node)
 | 
			
		||||
        def_node_matcher :empty_raise_error_or_exception, <<-PATTERN
 | 
			
		||||
          (send
 | 
			
		||||
            (block
 | 
			
		||||
@ -26,6 +26,7 @@ module RuboCop
 | 
			
		||||
        MSG = 'Prefer using verifying doubles over normal doubles.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[double spy].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method unverified_double(node)
 | 
			
		||||
        def_node_matcher :unverified_double, <<-PATTERN
 | 
			
		||||
          {(send nil? {:double :spy} $...)}
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -16,10 +16,12 @@ module RuboCop
 | 
			
		||||
              'Chain the methods or remove it.'
 | 
			
		||||
        RESTRICT_ON_SEND = %i[expect].freeze
 | 
			
		||||
 | 
			
		||||
        # @!method expect?(node)
 | 
			
		||||
        def_node_matcher :expect?, <<-PATTERN
 | 
			
		||||
          (send nil? :expect ...)
 | 
			
		||||
        PATTERN
 | 
			
		||||
 | 
			
		||||
        # @!method expect_block?(node)
 | 
			
		||||
        def_node_matcher :expect_block?, <<-PATTERN
 | 
			
		||||
          (block #expect? (args) _body)
 | 
			
		||||
        PATTERN
 | 
			
		||||
@ -17,10 +17,13 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
        MSG = 'Use `.and_yield`.'
 | 
			
		||||
 | 
			
		||||
        # @!method method_on_stub?(node)
 | 
			
		||||
        def_node_search :method_on_stub?, '(send nil? :receive ...)'
 | 
			
		||||
 | 
			
		||||
        # @!method block_arg(node)
 | 
			
		||||
        def_node_matcher :block_arg, '(args (blockarg $_))'
 | 
			
		||||
 | 
			
		||||
        # @!method block_call?(node)
 | 
			
		||||
        def_node_matcher :block_call?, '(send (lvar %) :call ...)'
 | 
			
		||||
 | 
			
		||||
        def on_block(node)
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user