Sha256: e52d2784cabe860456943eb0da5a8fdcdb4b425d62aa966e4711a529f6f9fea7

Contents?: true

Size: 624 Bytes

Versions: 4

Compression:

Stored size: 624 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe IfWithSemicolon do
      let(:iws) { IfWithSemicolon.new }

      it 'registers an offence for one line if/;/end' do
        inspect_source(iws, ['if cond; run else dont end'])
        expect(iws.offences.map(&:message)).to eq(
          ['Never use if x; Use the ternary operator instead.'])
      end

      it 'can handle modifier conditionals' do
        inspect_source(iws, ['class Hash',
                             'end if RUBY_VERSION < "1.8.7"'])
        expect(iws.offences.map(&:message)).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/if_with_semicolon_spec.rb
rubocop-0.8.2 spec/rubocop/cops/if_with_semicolon_spec.rb
rubocop-0.8.1 spec/rubocop/cops/if_with_semicolon_spec.rb
rubocop-0.8.0 spec/rubocop/cops/if_with_semicolon_spec.rb