Sha256: 2483ae821e2646897fa796bfeba124f157f7a486d868da2c629dd9223c79c52d

Contents?: true

Size: 897 Bytes

Versions: 4

Compression:

Stored size: 897 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe AndOr do
      let(:amp) { AndOr.new }

      it 'registers an offence for OR' do
        inspect_source(amp,
                       ['test if a or b'])
        expect(amp.offences.size).to eq(1)
        expect(amp.messages).to eq(['Use || instead of or.'])
      end

      it 'registers an offence for AND' do
        inspect_source(amp,
                       ['test if a and b'])
        expect(amp.offences.size).to eq(1)
        expect(amp.messages).to eq(['Use && instead of and.'])
      end

      it 'accepts ||' do
        inspect_source(amp,
                       ['test if a || b'])
        expect(amp.offences).to be_empty
      end

      it 'accepts &&' do
        inspect_source(amp,
                       ['test if a && b'])
        expect(amp.offences).to be_empty
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.8.3 spec/rubocop/cops/and_or_spec.rb
rubocop-0.8.2 spec/rubocop/cops/and_or_spec.rb
rubocop-0.8.1 spec/rubocop/cops/and_or_spec.rb
rubocop-0.8.0 spec/rubocop/cops/and_or_spec.rb