Sha256: a506130ffb23124cdd035fd4ed80d4744ae34ba33841c5873dc1fccdbd7c8eca

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 KB

Contents

require 'yard'

require 'rubocop/rspec/description_extractor'

RSpec.describe RuboCop::RSpec::DescriptionExtractor do
  let(:yardocs) do
    YARD.parse_string(<<-RUBY)
      # This is not a cop
      class RuboCop::Cop::Mixin::Sneaky
      end

      # This is not a concrete cop
      #
      # @abstract
      class RuboCop::Cop::RSpec::Cop
      end

      # Checks foo
      #
      # Some description
      #
      # @note only works with foo
      class RuboCop::Cop::RSpec::Foo
        # Hello
        def bar
        end
      end

      class RuboCop::Cop::RSpec::Undocumented
        # Hello
        def bar
        end
      end
    RUBY

    YARD::Registry.all
  end

  def stub_cop_const(name)
    stub_const(
      "RuboCop::Cop::RSpec::#{name}",
      Class.new(RuboCop::Cop.const_get(:WorkaroundCop))
    )
  end

  before do
    stub_cop_const('Foo')
    stub_cop_const('Undocumented')
  end

  it 'builds a hash of descriptions' do
    expect(described_class.new(yardocs).to_h).to eql(
      'RSpec/Foo'          => { 'Description' => 'Checks foo' },
      'RSpec/Undocumented' => { 'Description' => ''           }
    )
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubocop-rspec-1.21.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.19.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.18.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.17.1 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.17.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.16.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.15.1 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.15.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.14.0 spec/rubocop/rspec/description_extractor_spec.rb
rubocop-rspec-1.13.0 spec/rubocop/rspec/description_extractor_spec.rb