Sha256: f3e3e812764c04263065145febdb0ae1f2c579628fa40cd3c391cbafb0928ee2

Contents?: true

Size: 938 Bytes

Versions: 6

Compression:

Stored size: 938 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe Cop do
      let(:cop) { Cop.new }
      let(:location) do
        source_buffer = Parser::Source::Buffer.new('test', 1)
        source_buffer.source = "a\n"
        Parser::Source::Range.new(source_buffer, 0, 1)
      end

      it 'initially has 0 offences' do
        expect(cop.offences).to be_empty
      end

      it 'keeps track of offences' do
        cop.add_offence(:convention, location, 'message')

        expect(cop.offences.size).to eq(1)
      end

      it 'will report registered offences' do
        cop.add_offence(:convention, location, 'message')

        expect(cop.offences).not_to be_empty
      end

      it 'registers offence with its name' do
        cop = Style::AvoidFor.new
        cop.add_offence(:convention, location, 'message')
        expect(cop.offences.first.cop_name).to eq('AvoidFor')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rubocop-0.11.1 spec/rubocop/cop/cop_spec.rb
rubocop-0.11.0 spec/rubocop/cops/cop_spec.rb
rubocop-0.10.0 spec/rubocop/cops/cop_spec.rb
rubocop-0.9.1 spec/rubocop/cops/cop_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/cop_spec.rb
rubocop-0.9.0 spec/rubocop/cops/cop_spec.rb