Sha256: 8464d0ae918626d7ca73c4a324eef9f630bce2d071557306c5fd6726912e1e97

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

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

  it 'ignores describes with only a class' do
    inspect_source(cop, 'describe Some::Class do; end')
    expect(cop.offenses.empty?).to be(true)
  end

  it 'enforces non-method names' do
    inspect_source(
      cop,
      "describe Some::Class, 'nope', '.incorrect_usage' 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

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-rspec-1.5.2 spec/rubocop/cop/rspec/describe_method_spec.rb