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

modify_sidekiq_middleware_spec.rb « rspec « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d3d323b6643d78430416cdb18b777fb9b00fc607 (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
36
37
38
# frozen_string_literal: true

require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../../rubocop/cop/rspec/modify_sidekiq_middleware'

describe RuboCop::Cop::RSpec::ModifySidekiqMiddleware, type: :rubocop do
  include CopHelper
  include ExpectOffense

  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