Sha256: 3422546fb677fa0f7fd4a00b3e9341b1c52b764f7ea77b8f89abbf1ead6348e0
Contents?: true
Size: 1.09 KB
Versions: 6
Compression:
Stored size: 1.09 KB
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.33333 end it "avg returns 0 if values empty" do stats = Tabs::Metrics::Counter::Stats.new(period, resolution, []) expect(stats.avg).to be_zero end end
Version data entries
6 entries across 6 versions & 1 rubygems