Sha256: 5595a0fe7055b90136647d29fd10a8cd17ecb7ab4cd9022e419494b53c16b650

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

RSpec.describe RuboCop::Cop::RSpec::DescribeSymbol do
  subject(:cop) { described_class.new }

  it 'flags violations for `describe :symbol`' do
    expect_violation(<<-RUBY)
      describe(:some_method) { }
               ^^^^^^^^^^^^ Avoid describing symbols.
    RUBY
  end

  it 'flags violations for `describe :symbol` with multiple arguments' do
    expect_violation(<<-RUBY)
      describe(:some_method, "description") { }
               ^^^^^^^^^^^^ Avoid describing symbols.
    RUBY
  end

  it 'flags violations for `RSpec.describe :symbol`' do
    expect_violation(<<-RUBY)
      RSpec.describe(:some_method, "description") { }
                     ^^^^^^^^^^^^ Avoid describing symbols.
    RUBY
  end

  it 'flags violations for a nested `describe`' do
    expect_violation(<<-RUBY)
      RSpec.describe Foo do
        describe :to_s do
                 ^^^^^ Avoid describing symbols.
        end
      end
    RUBY
  end

  it 'does not flag non-Symbol arguments' do
    expect_no_violations('describe("#some_method") { }')
  end

  it 'does not flag `context :symbol`' do
    expect_no_violations('context(:some_method) { }')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-rspec-1.15.1 spec/rubocop/cop/rspec/describe_symbol_spec.rb
rubocop-rspec-1.15.0 spec/rubocop/cop/rspec/describe_symbol_spec.rb