Sha256: 232cce92a24e97fa145f38e8a6170fe97ea96ded563df9fdea8d134ee722fd3c

Contents?: true

Size: 861 Bytes

Versions: 30

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Avoid opening modules and defining specs within them.
      #
      # @example
      #   # bad
      #   module MyModule
      #     RSpec.describe MyClass do
      #       # ...
      #     end
      #   end
      #
      #   # good
      #   RSpec.describe MyModule::MyClass do
      #     # ...
      #   end
      #
      # @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)
          find_rspec_blocks(node) do
            add_offense(node)
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 26 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.12.1/lib/rubocop/cop/rspec/described_class_module_wrapping.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.13.1/lib/rubocop/cop/rspec/described_class_module_wrapping.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.9.0/lib/rubocop/cop/rspec/described_class_module_wrapping.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.12.1/lib/rubocop/cop/rspec/described_class_module_wrapping.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.13.1/lib/rubocop/cop/rspec/described_class_module_wrapping.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.9.0/lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.18.1 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.18.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.17.1 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.17.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.16.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.15.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.14.2 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.14.1 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.14.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.13.2 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.13.1 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.13.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.12.1 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.12.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb