Sha256: 51bd97c1179de4389efeb30b7b9a3b74a58779f87d34732628b5da53a0492dc9
Contents?: true
Size: 1.61 KB
Versions: 6
Compression:
Stored size: 1.61 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Lint::ElseLayout do subject(:cop) { described_class.new } it 'registers an offense for expr on same line as else' do inspect_source(cop, ['if something', ' test', 'else ala', ' something', ' test', 'end' ]) expect(cop.offenses.size).to eq(1) end it 'accepts proper else' do inspect_source(cop, ['if something', ' test', 'else', ' something', ' test', 'end' ]) expect(cop.offenses).to be_empty end it 'accepts single-expr else regardless of layout' do inspect_source(cop, ['if something', ' test', 'else bala', 'end' ]) expect(cop.offenses).to be_empty end it 'can handle elsifs' do inspect_source(cop, ['if something', ' test', 'elsif something', ' bala', 'else ala', ' something', ' test', 'end' ]) expect(cop.offenses.size).to eq(1) end it 'handles ternary ops' do inspect_source(cop, 'x ? a : b') expect(cop.offenses).to be_empty end it 'handles modifier forms' do inspect_source(cop, 'x if something') expect(cop.offenses).to be_empty end end
Version data entries
6 entries across 6 versions & 1 rubygems