Sha256: f9dd44f97245dc374fc3e8ba23b701706639f485351f6bc333df0a36dc8cba83
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
# encoding: utf-8 describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do subject(:cop) { described_class.new(config) } it 'finds a `double` instead of an `instance_double`' do inspect_source(cop, ['it do', ' foo = double("Widget")', 'end']) expect(cop.messages) .to eq(['Prefer using verifying doubles over normal doubles.']) expect(cop.highlights).to eq(['double("Widget")']) expect(cop.offenses.map(&:line).sort).to eq([2]) end it 'finds a `spy` instead of an `instance_spy`' do inspect_source(cop, ['it do', ' foo = spy("Widget")', 'end']) expect(cop.messages) .to eq(['Prefer using verifying doubles over normal doubles.']) expect(cop.highlights).to eq(['spy("Widget")']) expect(cop.offenses.map(&:line).sort).to eq([2]) end it 'find doubles whose name is a symbol' do inspect_source(cop, ['it do', ' foo = double(:widget)', 'end']) expect(cop.messages) .to eq(['Prefer using verifying doubles over normal doubles.']) expect(cop.highlights).to eq(['double(:widget)']) expect(cop.offenses.map(&:line).sort).to eq([2]) end context 'when configured to ignore symbolic names' do let(:cop_config) { { 'IgnoreSymbolicNames' => true } } it 'ignores doubles whose name is a symbol' do inspect_source(cop, ['it do', ' foo = double(:widget)', 'end']) expect(cop.messages).to be_empty end end it 'ignores doubles without a name' do inspect_source(cop, ['it do', ' foo = double', 'end']) expect(cop.messages).to be_empty end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.5.1 | spec/rubocop/cop/rspec/verified_doubles_spec.rb |
rubocop-rspec-1.5.0 | spec/rubocop/cop/rspec/verified_doubles_spec.rb |