Sha256: 52d9f1fcc234c5cec58f605d17a05da644e7cc1cbc8c8dc6dd8ff4dc55904188

Contents?: true

Size: 634 Bytes

Versions: 10

Compression:

Stored size: 634 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
    inspect_source(<<~RUBY)
    expect(user.created_at).to eq(Time.zone.now)
    RUBY

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

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

    expect(cop.offenses).to be_empty
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-discourse-3.8.1 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.7.1 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.7.0 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.6.1 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.6.0 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.5.1 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.5.0 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.4.1 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.4.0 spec/lib/rubocop/cop/time_eq_matcher_spec.rb
rubocop-discourse-3.3.0 spec/lib/rubocop/cop/time_eq_matcher_spec.rb