Sha256: 3a5b21cfe2f3be2a1af3707e943572e42c8926fec8c53c37a013d84d5263998c

Contents?: true

Size: 855 Bytes

Versions: 6

Compression:

Stored size: 855 Bytes

Contents

# encoding: utf-8

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

  it 'enforces non-method names' do
    inspect_source(cop, "describe Some::Class, 'nope' do; end")
    expect(cop.offenses.size).to eq(1)
    expect(cop.offenses.map(&:line).sort).to eq([1])
    expect(cop.messages)
      .to eq(['The second argument to describe should be the method being ' \
              "tested. '#instance' or '.class'"])
  end

  it 'skips methods starting with a . or #' do
    inspect_source(cop, ["describe Some::Class, '.asdf' do; end",
                         "describe Some::Class, '#fdsa' do; end"])
    expect(cop.offenses).to be_empty
  end

  it 'skips specs not having a string second argument' do
    inspect_source(cop, 'describe Some::Class, :config do; end')

    expect(cop.offenses).to be_empty
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-rspec-1.5.1 spec/rubocop/cop/rspec/describe_method_spec.rb
rubocop-rspec-1.5.0 spec/rubocop/cop/rspec/describe_method_spec.rb
rubocop-rspec-1.4.1 spec/rubocop/cop/rspec/describe_method_spec.rb
rubocop-rspec-1.4.0 spec/rubocop/cop/rspec/describe_method_spec.rb
rubocop-rspec-1.3.1 spec/rubocop/cop/rspec/describe_method_spec.rb
rubocop-rspec-1.3.0 spec/rubocop/cop/rspec/describe_method_spec.rb