2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
require 'fast_spec_helper'
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
require 'rubocop'
|
|
|
|
require 'rubocop/rspec/support'
|
|
|
|
|
|
|
|
require_relative '../../../rubocop/cop/include_sidekiq_worker'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe RuboCop::Cop::IncludeSidekiqWorker, type: :rubocop do
|
2018-03-17 18:26:18 +05:30
|
|
|
include CopHelper
|
|
|
|
|
|
|
|
subject(:cop) { described_class.new }
|
|
|
|
|
|
|
|
context 'when `Sidekiq::Worker` is included' do
|
|
|
|
let(:source) { 'include Sidekiq::Worker' }
|
|
|
|
let(:correct_source) { 'include ApplicationWorker' }
|
|
|
|
|
|
|
|
it 'registers an offense ' do
|
|
|
|
inspect_source(source)
|
|
|
|
|
|
|
|
aggregate_failures do
|
|
|
|
expect(cop.offenses.size).to eq(1)
|
|
|
|
expect(cop.offenses.map(&:line)).to eq([1])
|
|
|
|
expect(cop.highlights).to eq(['Sidekiq::Worker'])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'autocorrects to the right version' do
|
|
|
|
autocorrected = autocorrect_source(source)
|
|
|
|
|
|
|
|
expect(autocorrected).to eq(correct_source)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|