debian-mirror-gitlab/spec/rubocop/cop/scalability/idempotent_worker_spec.rb
2021-04-17 20:07:23 +05:30

31 lines
694 B
Ruby

# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../../rubocop/cop/scalability/idempotent_worker'
RSpec.describe RuboCop::Cop::Scalability::IdempotentWorker do
subject(:cop) { described_class.new }
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