Sha256: 144f4a8d73c1c7d91a84d70e2a1960896002145453c9d9c7101bf9365b3d435d

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe TernaryOperator do
      let (:num) { TernaryOperator.new }

      it 'registers an offence for a multiline ternary operator expression' do
        inspect_source(num, 'file.rb', ['a = cond ?',
                                        '  b : c'])
        num.offences.map(&:message).should ==
          ['Avoid multi-line ?: (the ternary operator); use if/unless ' +
           'instead.']
      end

      it 'accepts a single line ternary operator expression' do
        inspect_source(num, 'file.rb', ['a = cond ? b : c'])
        num.offences.map(&:message).should == []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.2.1 spec/rubocop/cops/ternary_operator_spec.rb