Sha256: 6338f7903e1baac4690428916e41a915cfb2b6f5c75dbd5d7d646011ec3f21ef

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module RuboCop
  module RSpec
    module Language
      # Common node matchers used for matching against the rspec DSL
      module NodePattern
        extend RuboCop::NodePattern::Macros

        def_node_matcher :rspec?, '{(const {nil? cbase} :RSpec) nil?}'

        def_node_matcher :example_group?, ExampleGroups::ALL.block_pattern
        def_node_matcher :shared_group?, SharedGroups::ALL.block_pattern

        spec_groups = ExampleGroups::ALL + SharedGroups::ALL
        def_node_matcher :spec_group?, spec_groups.block_pattern

        def_node_matcher :example_group_with_body?, <<-PATTERN
          (block #{ExampleGroups::ALL.send_pattern} args !nil?)
        PATTERN

        def_node_matcher :example?, Examples::ALL.block_pattern

        def_node_matcher :hook?, Hooks::ALL.block_pattern

        def_node_matcher :let?, Helpers::ALL.block_or_block_pass_pattern

        def_node_matcher :include?,
                         Includes::ALL.send_or_block_or_block_pass_pattern

        def_node_matcher :subject?, Subject::ALL.block_pattern
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-rspec-2.0.0.pre lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-1.44.1 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-1.44.0 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-1.43.2 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-1.43.1 lib/rubocop/rspec/language/node_pattern.rb
rubocop-rspec-1.43.0 lib/rubocop/rspec/language/node_pattern.rb