Sha256: 7bd541b9e47f0a6e352d759291b5928f321d029028b12939d979f59039f8f60e
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Style::EvenOdd do subject(:cop) { described_class.new } it 'registers an offense for x % 2 == 0' do inspect_source(cop, ['x % 2 == 0']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.even?']) end it 'registers an offense for x % 2 != 0' do inspect_source(cop, ['x % 2 != 0']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.odd?']) end it 'registers an offense for (x % 2) == 0' do inspect_source(cop, ['(x % 2) == 0']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.even?']) end it 'registers an offense for (x % 2) != 0' do inspect_source(cop, ['(x % 2) != 0']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.odd?']) end it 'registers an offense for x % 2 == 1' do inspect_source(cop, ['x % 2 == 1']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.odd?']) end it 'registers an offense for x % 2 != 1' do inspect_source(cop, ['x % 2 != 1']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.even?']) end it 'registers an offense for (x % 2) == 1' do inspect_source(cop, ['(x % 2) == 1']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.odd?']) end it 'registers an offense for (x % 2) != 1' do inspect_source(cop, ['(x % 2) != 1']) expect(cop.offenses.size).to eq(1) expect(cop.messages).to eq(['Use Fixnum.even?']) end it 'accepts x % 3 == 0' do inspect_source(cop, ['x % 3 == 0']) expect(cop.offenses).to be_empty end it 'accepts x % 3 != 0' do inspect_source(cop, ['x % 3 != 0']) expect(cop.offenses).to be_empty end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | spec/rubocop/cop/style/even_odd_spec.rb |
rubocop-0.19.0 | spec/rubocop/cop/style/even_odd_spec.rb |