Sha256: ab838ba8c2b2ed3868a55d07957eef479981fd42be9cded48b486525ac78fac2

Contents?: true

Size: 807 Bytes

Versions: 11

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

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/lint/useless_comparison_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.28.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.27.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.27.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.26.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.26.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.25.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.24.1 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.24.0 spec/rubocop/cop/lint/useless_comparison_spec.rb
rubocop-0.23.0 spec/rubocop/cop/lint/useless_comparison_spec.rb