Sha256: 429ebb9dee99db3ed7a12bc52da673d5c309c44c0bc0c10295237813d6441446
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Style::NonNilCheck do subject(:cop) { described_class.new } it 'registers an offense for != nil' do inspect_source(cop, 'x != nil') expect(cop.offenses.size).to eq(1) expect(cop.highlights).to eq(['!=']) end it 'registers an offense for !x.nil?' do inspect_source(cop, '!x.nil?') expect(cop.offenses.size).to eq(1) expect(cop.highlights).to eq(['!x.nil?']) end it 'registers an offense for not x.nil?' do inspect_source(cop, 'not x.nil?') expect(cop.offenses.size).to eq(1) expect(cop.highlights).to eq(['not x.nil?']) end it 'autocorrects by removing != nil' do corrected = autocorrect_source(cop, 'x != nil') expect(corrected).to eq 'x' end it 'autocorrects by removing non-nil (!x.nil?) check' do corrected = autocorrect_source(cop, '!x.nil?') expect(corrected).to eq 'x' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.20.0 | spec/rubocop/cop/style/non_nil_check_spec.rb |