Sha256: 150ba81ed393688eea95a983254a0fa9e480732eccf36800a2c90d92742dad3d

Contents?: true

Size: 950 Bytes

Versions: 7

Compression:

Stored size: 950 Bytes

Contents

require "spec_helper"

module QueueMetricTracker
  describe StatCalculator do
    let(:granularity)         { 10 }
    let(:default_granularity) { 100 }
    subject(:calculator) { described_class }

    it "responds to new with a granularity" do
      expect(calculator.new(granularity).granularity).to eq(granularity)
    end

    it "granularity defaults to a value" do
      expect(calculator.new().granularity).to eq(default_granularity)
    end

    describe "#add" do
      let(:granularity)         { 3 }
      let(:value1)              { 4 }
      let(:value2)              { 3 }
      let(:value3)              { 8 }
      let(:average)             { 5 }
      subject(:calculator)      { described_class.new(granularity) }

      it "calculates average of N values" do
        expect(subject.add(value1)).to be_nil
        expect(subject.add(value2)).to be_nil
        expect(subject.add(value3)).to eq(average)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nexia_worker_roulette-0.2.9 spec/unit/stat_calculator_spec.rb
nexia_worker_roulette-0.2.8 spec/unit/stat_calculator_spec.rb
nexia_worker_roulette-0.2.7 spec/unit/stat_calculator_spec.rb
nexia_worker_roulette-0.2.6 spec/unit/stat_calculator_spec.rb
nexia_worker_roulette-0.2.5 spec/unit/stat_calculator_spec.rb
nexia_worker_roulette-0.2.4 spec/unit/stat_calculator_spec.rb
nexia_worker_roulette-0.2.3 spec/unit/stat_calculator_spec.rb