summaryrefslogtreecommitdiff
path: root/spec/rubocop/cop/scalability/idempotent_worker_spec.rb
blob: b198472180336f7c18b4abc328822dfb433ce445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/scalability/idempotent_worker'

RSpec.describe RuboCop::Cop::Scalability::IdempotentWorker do
  before do
    allow(cop)
      .to receive(:in_worker?)
      .and_return(true)
  end

  it 'adds an offense when not defining idempotent method' do
    expect_offense(<<~CODE)
      class SomeWorker
      ^^^^^^^^^^^^^^^^ Avoid adding not idempotent workers.[...]
      end
    CODE
  end

  it 'adds an offense when not defining idempotent method' do
    expect_no_offenses(<<~CODE)
      class SomeWorker
        idempotent!
      end
    CODE
  end
end