Sha256: 39ba52f8993c9d4328bc32d789f7a433de883aa481ea686ebb7dda1476562bea

Contents?: true

Size: 842 Bytes

Versions: 6

Compression:

Stored size: 842 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-hq/rubocop-rspec/issues/735
      class DescribedClassModuleWrapping < Base
        MSG = 'Avoid opening modules and defining specs within them.'

        def_node_search :find_rspec_blocks,
                        ExampleGroups::ALL.block_pattern

        def on_module(node)
          find_rspec_blocks(node) do
            add_offense(node)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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