Sha256: b22da39d46a5bd62ffd09ca35164760dfdc0b661af87b1e78c1ff9202b62b67b

Contents?: true

Size: 807 Bytes

Versions: 8

Compression:

Stored size: 807 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Lint::UselessComparison do
  subject(:cop) { described_class.new }

  described_class::OPS.each do |op|
    it "registers an offence for a simple comparison with #{op}" do
      inspect_source(cop,
                     ["5 #{op} 5",
                      "a #{op} a"
                     ])
      expect(cop.offences.size).to eq(2)
    end

    it "registers an offence for a complex comparison with #{op}" do
      inspect_source(cop,
                     ["5 + 10 * 30 #{op} 5 + 10 * 30",
                      "a.top(x) #{op} a.top(x)"
                     ])
      expect(cop.offences.size).to eq(2)
    end
  end

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ridecharge-rubocop-0.0.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.18.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.18.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.17.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.16.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.15.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.14.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.14.0 spec/rubocop/cop/lint/useless_comparison_spec.rb