Sha256: 4798b9046f4eb2ffc08df001f66a12a49bccc3a0b2ce1a2db2ae99c652ec59bf

Contents?: true

Size: 529 Bytes

Versions: 6

Compression:

Stored size: 529 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::IfWithSemicolon do
  subject(:cop) { described_class.new }

  it 'registers an offense for one line if/;/end' do
    inspect_source(cop, ['if cond; run else dont end'])
    expect(cop.messages).to eq(
      ['Never use if x; Use the ternary operator instead.'])
  end

  it 'can handle modifier conditionals' do
    inspect_source(cop, ['class Hash',
                         'end if RUBY_VERSION < "1.8.7"'])
    expect(cop.messages).to be_empty
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/style/if_with_semicolon_spec.rb
rubocop-0.21.0 spec/rubocop/cop/style/if_with_semicolon_spec.rb
rubocop-0.20.1 spec/rubocop/cop/style/if_with_semicolon_spec.rb
rubocop-0.20.0 spec/rubocop/cop/style/if_with_semicolon_spec.rb
rubocop-0.19.1 spec/rubocop/cop/style/if_with_semicolon_spec.rb
rubocop-0.19.0 spec/rubocop/cop/style/if_with_semicolon_spec.rb