diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-05 18:01:05 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-09 14:29:10 +0100 |
commit | 265ef867fff165643784640d837579ce4fcc2207 (patch) | |
tree | a5b8aa1a17960c66ea3950b4f71c5ba093bdca12 /spec/lib/gitlab/sherlock/line_sample_spec.rb | |
parent | dec3e4ce64df5f71a7cba7734cada1baa79242cd (diff) | |
download | gitlab-ce-265ef867fff165643784640d837579ce4fcc2207.tar.gz |
Added specs and source documentation for Sherlock
Diffstat (limited to 'spec/lib/gitlab/sherlock/line_sample_spec.rb')
-rw-r--r-- | spec/lib/gitlab/sherlock/line_sample_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sherlock/line_sample_spec.rb b/spec/lib/gitlab/sherlock/line_sample_spec.rb new file mode 100644 index 00000000000..5f02f6a3213 --- /dev/null +++ b/spec/lib/gitlab/sherlock/line_sample_spec.rb @@ -0,0 +1,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 |