2020-04-21 11:21:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'fast_spec_helper'
|
|
|
|
require_relative '../../../../rubocop/cop/rspec/modify_sidekiq_middleware'
|
|
|
|
|
2021-01-07 13:10:38 -05:00
|
|
|
RSpec.describe RuboCop::Cop::RSpec::ModifySidekiqMiddleware do
|
2020-04-21 11:21:10 -04:00
|
|
|
subject(:cop) { described_class.new }
|
|
|
|
|
2021-02-09 01:09:21 -05:00
|
|
|
it 'registers an offense and corrects', :aggregate_failures do
|
|
|
|
expect_offense(<<~CODE)
|
|
|
|
Sidekiq::Testing.server_middleware do |chain|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't modify global sidekiq middleware, [...]
|
|
|
|
chain.add(MyCustomMiddleware)
|
|
|
|
end
|
|
|
|
CODE
|
|
|
|
|
|
|
|
expect_correction(<<~CODE)
|
|
|
|
with_sidekiq_server_middleware do |chain|
|
|
|
|
chain.add(MyCustomMiddleware)
|
|
|
|
end
|
|
|
|
CODE
|
2020-04-21 11:21:10 -04:00
|
|
|
end
|
|
|
|
end
|