Sha256: d3af54e4a6c2d10c86c3b22a89fbbce7d962d4b06e86722ce40ff7415a0a423d
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe AndOr do let(:cop) { AndOr.new } it 'registers an offence for OR' do inspect_source(cop, ['test if a or b']) expect(cop.offences.size).to eq(1) expect(cop.messages).to eq(['Use || instead of or.']) end it 'registers an offence for AND' do inspect_source(cop, ['test if a and b']) expect(cop.offences.size).to eq(1) expect(cop.messages).to eq(['Use && instead of and.']) end it 'accepts ||' do inspect_source(cop, ['test if a || b']) expect(cop.offences).to be_empty end it 'accepts &&' do inspect_source(cop, ['test if a && b']) expect(cop.offences).to be_empty end it 'auto-corrects "and" with &&' do new_source = autocorrect_source(cop, 'true and false') expect(new_source).to eq('true && false') end it 'auto-corrects "or" with ||' do new_source = autocorrect_source(cop, 'true or false') expect(new_source).to eq('true || false') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.10.0 | spec/rubocop/cops/style/and_or_spec.rb |