Sha256: 64b763ee201ad4f359e5ce84ab9b4823ed9c3be3cfec2fe31a7545dcce135fca
Contents?: true
Size: 1.37 KB
Versions: 11
Compression:
Stored size: 1.37 KB
Contents
# encoding: utf-8 require 'spec_helper' describe RuboCop::Cop::Lint::ConditionPosition do subject(:cop) { described_class.new } %w(if unless while until).each do |keyword| it 'registers an offense for condition on the next line' do inspect_source(cop, ["#{keyword}", 'x == 10', 'end' ]) expect(cop.offenses.size).to eq(1) end it 'accepts condition on the same line' do inspect_source(cop, ["#{keyword} x == 10", ' bala', 'end' ]) expect(cop.offenses).to be_empty end it 'accepts condition on a different line for modifiers' do inspect_source(cop, ["do_something #{keyword}", ' something && something_else']) expect(cop.offenses).to be_empty end end it 'registers an offense for elsif condition on the next line' do inspect_source(cop, ['if something', ' test', 'elsif', ' 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 end
Version data entries
11 entries across 11 versions & 2 rubygems