Sha256: baf46b85825915dec8bd61e88d4ab4b746e233b797808ca6b88f4f45419a98e5

Contents?: true

Size: 838 Bytes

Versions: 7

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

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

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

  it "raises an offense if Jobs is mocked with :enqueue" do
    offenses = inspect_source(<<~RUBY)
    Jobs.expects(:enqueue)
    RUBY

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

  it "raises an offense if Jobs is mocked with :enqueue_in" do
    offenses = inspect_source(<<~RUBY)
    Jobs.expects(:enqueue_in)
    RUBY

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

  it "does not raise an offense if Jobs is not mocked with :enqueue or :enqueue_in" do
    offenses = inspect_source(<<~RUBY)
    Jobs.enqueue(:some_job)
    RUBY

    expect(offenses).to eq([])
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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