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

duration_measuring_spec.rb « import_export « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cf8b60607416e7557787f6d206da26d5e5f4280d (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'

RSpec.describe Gitlab::ImportExport::DurationMeasuring do
  subject do
    Class.new do
      include Gitlab::ImportExport::DurationMeasuring

      def test
        with_duration_measuring do
          'test'
        end
      end
    end.new
  end

  it 'measures method execution duration' do
    subject.test

    expect(subject.duration_s).not_to be_nil
  end

  describe '#with_duration_measuring' do
    it 'yields control' do
      expect { |block| subject.with_duration_measuring(&block) }.to yield_control
    end

    it 'returns result of the yielded block' do
      return_value = 'return_value'

      expect(subject.with_duration_measuring { return_value }).to eq(return_value)
    end
  end
end