Sha256: f91a79aa1f11423874e4f4c39ae1a190d54f9f5acdc2f5eb4ed7751625923078

Contents?: true

Size: 972 Bytes

Versions: 3

Compression:

Stored size: 972 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      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
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 spec/rubocop/cops/style/and_or_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/style/and_or_spec.rb
rubocop-0.9.0 spec/rubocop/cops/style/and_or_spec.rb