Sha256: 1eb71d6416d61086fe48078d35824bad99fe3a954979d80b6265fb8fd613ef09

Contents?: true

Size: 690 Bytes

Versions: 2

Compression:

Stored size: 690 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::NilComparison 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)
  end

  it 'registers an offense for === nil' do
    inspect_source(cop,
                   ['x === nil'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'registers an offense for === nil' do
    inspect_source(cop,
                   ['x != nil'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'works with lambda.()' do
    inspect_source(cop, ['a.(x) == nil'])
    expect(cop.offenses.size).to eq(1)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.19.1 spec/rubocop/cop/style/nil_comparison_spec.rb
rubocop-0.19.0 spec/rubocop/cop/style/nil_comparison_spec.rb