Sha256: 6f4cadaa3f76c693dcf0d8540beb99c3dda4d9f2101aab60b896421f90895624

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8

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

  it 'finds multiple top level describes with class and method' do
    inspect_source(cop, ["describe MyClass, '.do_something' do; end",
                         "describe MyClass, '.do_something_else' do; end"])
    expect(cop.offenses.size).to eq(1)
    expect(cop.offenses.map(&:line).sort).to eq([1])
    expect(cop.messages).to eq(['Do not use multiple top level describes - ' \
                                'try to nest them.'])
  end

  it 'finds multiple top level describes only with class' do
    inspect_source(cop, ['describe MyClass do; end',
                         'describe MyOtherClass do; end'])
    expect(cop.offenses.size).to eq(1)
    expect(cop.offenses.map(&:line).sort).to eq([1])
    expect(cop.messages).to eq(['Do not use multiple top level describes - ' \
                                'try to nest them.'])
  end

  it 'skips single top level describe' do
    inspect_source(cop, ["require 'spec_helper'",
                         '',
                         'describe MyClass 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.4.1 spec/rubocop/cop/rspec/multiple_describes_spec.rb
rubocop-rspec-1.4.0 spec/rubocop/cop/rspec/multiple_describes_spec.rb
rubocop-rspec-1.3.1 spec/rubocop/cop/rspec/multiple_describes_spec.rb
rubocop-rspec-1.3.0 spec/rubocop/cop/rspec/multiple_describes_spec.rb
rubocop-rspec-1.2.2 spec/rubocop/cop/rspec/multiple_describes_spec.rb
rubocop-rspec-1.2.1 spec/rubocop/cop/rspec/multiple_describes_spec.rb