Sha256: 12efc4a97e6157612ef430b23c761b2347f657711c57e05263b0d1cb37956f12

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

        it 'registers an offence for one line if/;/end' do
          inspect_source(iws, ['if cond; run else dont end'])
          expect(iws.messages).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.messages).to be_empty
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.13.1 spec/rubocop/cop/style/if_with_semicolon_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/if_with_semicolon_spec.rb