Sha256: 2b34ae4d29b9e61bc7d7a2b0dbd6f13f58cadb5902a220284038bb57ef238ec4

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'checks first-line describe statements' do
    inspect_source(cop, ['describe "bad describe" do; end'])
    expect(cop.offenses.size).to eq(1)
    expect(cop.offenses.map(&:line).sort).to eq([1])
    expect(cop.messages).to eq(['The first argument to describe should be ' \
                                'the class or module being tested.'])
  end

  it 'checks describe statements after a require' do
    inspect_source(cop, ["require 'spec_helper'",
                         'describe "bad describe" do; end'])
    expect(cop.offenses.size).to eq(1)
    expect(cop.offenses.map(&:line).sort).to eq([2])
    expect(cop.messages).to eq(['The first argument to describe should be ' \
                                'the class or module being tested.'])
  end

  it 'ignores nested describe statements' do
    inspect_source(cop, ['describe Some::Class do',
                         '  describe "bad describe" do; end',
                         'end'])
    expect(cop.offenses).to be_empty
  end

  it "doesn't blow up on single-line describes" do
    inspect_source(cop, ['describe Some::Class'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-rspec-1.2.0 spec/rubocop/cop/rspec/describe_class_spec.rb
rubocop-rspec-1.1.0 spec/rubocop/cop/rspec/describe_class_spec.rb
rubocop-rspec-1.0.1 spec/rubocop/cop/rspec/describe_class_spec.rb
rubocop-rspec-1.0 spec/rubocop/cop/rspec/describe_class_spec.rb
rubocop-rspec-1.0.rc3 spec/rubocop/cop/rspec/describe_class_spec.rb