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
rubocop-rspec-2.11.1 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.11.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.10.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.9.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.8.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.7.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.6.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.5.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.4.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb
rubocop-rspec-2.3.0 lib/rubocop/cop/rspec/described_class_module_wrapping.rb