Sha256: 5d757ce28b82182dc53b37c0ba76555912e3901f637981a370eb65de3d69c886

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

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

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

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

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

  it 'flags violations for a nested `describe`' do
    expect_offense(<<-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_offenses('describe("#some_method") { }')
  end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.35.0 spec/rubocop/cop/rspec/describe_symbol_spec.rb
rubocop-rspec-1.34.1 spec/rubocop/cop/rspec/describe_symbol_spec.rb
rubocop-rspec-1.34.0 spec/rubocop/cop/rspec/describe_symbol_spec.rb
rubocop-rspec-1.33.0 spec/rubocop/cop/rspec/describe_symbol_spec.rb