debian-mirror-gitlab/spec/rubocop/cop/scalability/idempotent_worker_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
694 B
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../../rubocop/cop/scalability/idempotent_worker'
2021-03-08 18:12:59 +05:30
RSpec.describe RuboCop::Cop::Scalability::IdempotentWorker do
2020-04-08 14:13:33 +05:30
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
2021-03-11 19:13:27 +05:30
expect_offense(<<~CODE)
2020-04-08 14:13:33 +05:30
class SomeWorker
2021-03-11 19:13:27 +05:30
^^^^^^^^^^^^^^^^ Avoid adding not idempotent workers.[...]
2020-04-08 14:13:33 +05:30
end
CODE
end
it 'adds an offense when not defining idempotent method' do
2021-03-11 19:13:27 +05:30
expect_no_offenses(<<~CODE)
2020-04-08 14:13:33 +05:30
class SomeWorker
idempotent!
end
CODE
end
end