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

line_sample_spec.rb « sherlock « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f02f6a3213eb0b998f6b7c2edc6e5b78edbd2d2 (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
require 'spec_helper'

describe Gitlab::Sherlock::LineSample do
  let(:sample) { described_class.new(150.0, 4) }

  describe '#duration' do
    it 'returns the duration' do
      expect(sample.duration).to eq(150.0)
    end
  end

  describe '#events' do
    it 'returns the amount of events' do
      expect(sample.events).to eq(4)
    end
  end

  describe '#percentage_of' do
    it 'returns the percentage of 1500.0' do
      expect(sample.percentage_of(1500.0)).to be_within(0.1).of(10.0)
    end
  end

  describe '#majority_of' do
    it 'returns true if the sample takes up the majority of the given duration' do
      expect(sample.majority_of?(500.0)).to eq(true)
    end

    it "returns false if the sample doesn't take up the majority of the given duration" do
      expect(sample.majority_of?(1500.0)).to eq(false)
    end
  end
end