Sha256: ccf7fc55e465b9e13dd766c85756b9e942c9b7e476f49ab336ff4e01e69bfcac
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Style::FavorUntilOverNegatedWhile do subject(:cop) { described_class.new } it 'registers an offence for while with exclamation point condition' do inspect_source(cop, ['while !a_condition', ' some_method', 'end', 'some_method while !a_condition', ]) expect(cop.messages).to eq( ['Favor until over while for negative conditions.'] * 2) end it 'registers an offence for while with "not" condition' do inspect_source(cop, ['while (not a_condition)', ' some_method', 'end', 'some_method while not a_condition']) expect(cop.messages).to eq( ['Favor until over while for negative conditions.'] * 2) expect(cop.offences.map(&:line)).to eq([1, 4]) end it 'accepts an while where only part of the contition is negated' do inspect_source(cop, ['while !a_condition && another_condition', ' some_method', 'end', 'while not a_condition or another_condition', ' some_method', 'end', 'some_method while not a_condition or other_cond']) expect(cop.messages).to be_empty end end
Version data entries
4 entries across 4 versions & 1 rubygems