Sha256: 30252eadc53a51684eced753f9be208b9641b12d76802d2b5d5712a5e196c722

Contents?: true

Size: 648 Bytes

Versions: 5

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

describe RuboCop::Cop::Discourse::TimeEqMatcher, :config do
  subject(:cop) { described_class.new(config) }

  let(:config) { RuboCop::Config.new }

  it "raises an offense if a timestamp is compared using `eq`" do
    offenses = inspect_source(<<~RUBY)
    expect(user.created_at).to eq(Time.zone.now)
    RUBY

    expect(offenses.first.message).to match(described_class::MSG)
  end

  it "passes if a timestamp is compared using `eq_time`" do
    offenses = inspect_source(<<~RUBY)
      expect(user.created_at).to eq_time(Time.zone.now)
    RUBY

    expect(offenses).to be_empty
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-discourse-3.8.6 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.8.5 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.8.4 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.8.3 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.8.2 spec/lib/rubocop/cop/time_eq_matcher_spec.rb