spec/rubocop/cops/cop_spec.rb in rubocop-0.8.3 vs spec/rubocop/cops/cop_spec.rb in rubocop-0.9.0
- old
+ new
@@ -4,28 +4,35 @@
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 'initially has nothing to report' do
- expect(cop.has_report?).to be_false
- end
-
it 'keeps track of offences' do
- cop.add_offence(:convention, 1, 'message')
+ cop.add_offence(:convention, location, 'message')
expect(cop.offences.size).to eq(1)
end
it 'will report registered offences' do
- cop.add_offence(:convention, 1, 'message')
+ cop.add_offence(:convention, location, 'message')
- expect(cop.has_report?).to be_true
+ 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