Sha256: daff51a5880ee4ec050dd788375a6fff7de2733748df954334e46b46271c74bd
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop describe MultilineTernaryOperator do let(:op) { MultilineTernaryOperator.new } it 'registers an offence for a multiline ternary operator expression' do inspect_source(op, ['a = cond ?', ' b : c']) expect(op.offences.size).to eq(1) end it 'accepts a single line ternary operator expression' do inspect_source(op, ['a = cond ? b : c']) expect(op.offences).to be_empty end end describe NestedTernaryOperator do let(:op) { NestedTernaryOperator.new } it 'registers an offence for a nested ternary operator expression' do inspect_source(op, ['a ? (b ? b1 : b2) : a2']) expect(op.offences.size).to eq(1) end it 'accepts a non-nested ternary operator within an if' do inspect_source(op, ['a = if x', ' cond ? b : c', 'else', ' d', 'end']) expect(op.offences).to be_empty end end end end
Version data entries
4 entries across 4 versions & 1 rubygems