2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'fast_spec_helper'
|
|
|
|
require 'rubocop'
|
|
|
|
require_relative '../../../../rubocop/cop/rspec/modify_sidekiq_middleware'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe RuboCop::Cop::RSpec::ModifySidekiqMiddleware, type: :rubocop do
|
2020-04-22 19:07:51 +05:30
|
|
|
include CopHelper
|
|
|
|
|
|
|
|
subject(:cop) { described_class.new }
|
|
|
|
|
|
|
|
let(:source) do
|
|
|
|
<<~SRC
|
|
|
|
Sidekiq::Testing.server_middleware do |chain|
|
|
|
|
chain.add(MyCustomMiddleware)
|
|
|
|
end
|
|
|
|
SRC
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:corrected) do
|
|
|
|
<<~SRC
|
|
|
|
with_sidekiq_server_middleware do |chain|
|
|
|
|
chain.add(MyCustomMiddleware)
|
|
|
|
end
|
|
|
|
SRC
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'registers an offence' do
|
|
|
|
inspect_source(source)
|
|
|
|
|
|
|
|
expect(cop.offenses.size).to eq(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can autocorrect the source' do
|
|
|
|
expect(autocorrect_source(source)).to eq(corrected)
|
|
|
|
end
|
|
|
|
end
|