Sha256: 510c6421c0795cf213ba5416a69eb29c3c73f3b53e16d0bd6da9153d339e38f7

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

require "spec_helper"

describe Tabs::Metrics::Counter::Stats do

  let(:period) { (Time.now - 2.days..Time.now) }
  let(:resolution) { :hour }
  let(:values) do
    [
      { "timestamp" => Time.now - 30.hours, "count" => 44 },
      { "timestamp" => Time.now - 20.hours, "count" => 123 },
      { "timestamp" => Time.now - 10.hours, "count" => 92 }
    ]
  end
  let(:stats) { Tabs::Metrics::Counter::Stats.new(period, resolution, values) }

  it "is enumerable" do
    expect(stats).to respond_to :each
    expect(Tabs::Metrics::Counter::Stats.ancestors).to include Enumerable
  end

  it "#total returns the total count for the entire set" do
    expect(stats.total).to eq 259
  end

  it "min returns the min for the entire set" do
    expect(stats.min).to eq 44
  end

  it "max returns the max for the entire set" do
    expect(stats.max).to eq 123
  end

  it "avg returns the average for the entire set" do
    expect(stats.avg).to eq 86.33
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tabs-0.8.0 spec/lib/tabs/metrics/counter/stats_spec.rb