2017-12-12 11:21:00 -05:00
|
|
|
require 'spec_helper'
|
2017-09-19 11:25:42 -04:00
|
|
|
|
2017-12-12 11:21:00 -05:00
|
|
|
require 'rubocop'
|
|
|
|
require 'rubocop/rspec/support'
|
2017-09-19 11:25:42 -04:00
|
|
|
|
2017-12-12 11:21:00 -05:00
|
|
|
require_relative '../../../rubocop/cop/sidekiq_options_queue'
|
|
|
|
|
|
|
|
describe RuboCop::Cop::SidekiqOptionsQueue do
|
|
|
|
include CopHelper
|
|
|
|
|
|
|
|
subject(:cop) { described_class.new }
|
|
|
|
|
|
|
|
it 'registers an offense when `sidekiq_options` is used with the `queue` option' do
|
2017-09-19 11:25:42 -04:00
|
|
|
inspect_source('sidekiq_options queue: "some_queue"')
|
2017-12-12 11:21:00 -05:00
|
|
|
|
|
|
|
aggregate_failures do
|
|
|
|
expect(cop.offenses.size).to eq(1)
|
|
|
|
expect(cop.offenses.map(&:line)).to eq([1])
|
|
|
|
expect(cop.highlights).to eq(['queue: "some_queue"'])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not register an offense when `sidekiq_options` is used with another option' do
|
2017-09-19 11:25:42 -04:00
|
|
|
inspect_source('sidekiq_options retry: false')
|
2017-12-12 11:21:00 -05:00
|
|
|
|
|
|
|
expect(cop.offenses).to be_empty
|
|
|
|
end
|
|
|
|
end
|