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

measurable_shared_examples.rb « import_export « gitlab « tasks « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 45b2c5eac3ae875dcbd16af62dfcf42bcf67a040 (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
# frozen_string_literal: true

RSpec.shared_examples 'measurable' do
  context 'when measurement is enabled' do
    let(:measurement_enabled) { true }

    it 'prints measurement results' do
      expect { subject }.to output(including('Measuring enabled...', 'Number of sql calls:', 'Total GC count:', 'Total GC count:')).to_stdout
    end
  end

  context 'when measurement is not enabled' do
    let(:measurement_enabled) { false }

    it 'does not output measurement results' do
      expect { subject }.not_to output(/Measuring enabled.../).to_stdout
    end
  end

  context 'when measurement is not provided' do
    let(:measurement_enabled) { nil }

    it 'does not output measurement results' do
      expect { subject }.not_to output(/Measuring enabled.../).to_stdout
    end

    it 'does not raise any exception' do
      expect { subject }.not_to raise_error
    end
  end
end