Welcome to mirror list, hosted at ThFree Co, Russian Federation.

include_sidekiq_worker_spec.rb « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d056c6a13e7d9d73f371671190f4b7565284369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'fast_spec_helper'

require 'rubocop'
require 'rubocop/rspec/support'

require_relative '../../../rubocop/cop/include_sidekiq_worker'

RSpec.describe RuboCop::Cop::IncludeSidekiqWorker, type: :rubocop do
  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