Sha256: 159625492bcc4fa8fa9ee6e2f6f96002b50ebcd6dcb85d0cfe31e6c51c3d18d3

Contents?: true

Size: 807 Bytes

Versions: 6

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 offense for a simple comparison with #{op}" do
      inspect_source(cop,
                     ["5 #{op} 5",
                      "a #{op} a"
                     ])
      expect(cop.offenses.size).to eq(2)
    end

    it "registers an offense 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.offenses.size).to eq(2)
    end
  end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.21.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.20.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.20.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.19.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.19.0 spec/rubocop/cop/lint/useless_comparison_spec.rb