spec/lib/tabs/metrics/value_spec.rb in tabs-0.8.1 vs spec/lib/tabs/metrics/value_spec.rb in tabs-0.8.2
- old
+ new
@@ -14,11 +14,11 @@
it "sets the expected values for the period" do
metric.record(17)
metric.record(42)
time = Time.utc(now.year, now.month, now.day, now.hour)
stats = metric.stats(((now - 2.hours)..(now + 4.hours)), :hour)
- expect(stats).to include({ "timestamp"=>time, "count"=>2, "min"=>17, "max"=>42, "sum"=>59, "avg"=>29})
+ expect(stats).to include({ "timestamp"=>time, "count"=>2, "min"=>17, "max"=>42, "sum"=>59, "avg"=>29.5})
end
it "applys the value to the specified timestamp if one is supplied" do
time = Time.utc(now.year, now.month, now.day, now.hour) - 2.hours
metric.record(42, time)
@@ -56,45 +56,45 @@
it "returns the expected results for an minutely metric" do
create_span(:minutes)
stats = metric.stats(now..(now + 7.minutes), :minute)
expect(stats).to include({ "timestamp" => (now + 3.minutes), "count"=>1, "min"=>10, "max"=>10, "sum"=>10, "avg"=>10})
- expect(stats).to include({ "timestamp" => (now + 6.minutes), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17})
+ expect(stats).to include({ "timestamp" => (now + 6.minutes), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17.5})
end
it "returns the expected results for an hourly metric" do
create_span(:hours)
stats = metric.stats(now..(now + 7.hours), :hour)
expect(stats).to include({ "timestamp" => (now + 3.hours), "count"=>1, "min"=>10, "max"=>10, "sum"=>10, "avg"=>10})
- expect(stats).to include({ "timestamp" => (now + 6.hours), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17})
+ expect(stats).to include({ "timestamp" => (now + 6.hours), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17.5})
end
it "returns the expected results for a daily metric" do
create_span(:days)
stats = metric.stats(now..(now + 7.days), :day)
expect(stats).to include({ "timestamp" => (now + 3.days), "count"=>1, "min"=>10, "max"=>10, "sum"=>10, "avg"=>10})
- expect(stats).to include({ "timestamp" => (now + 6.days), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17})
+ expect(stats).to include({ "timestamp" => (now + 6.days), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17.5})
end
it "returns the expected results for a weekly metric" do
create_span(:weeks)
stats = metric.stats(now..(now + 7.weeks), :week)
expect(stats).to include({ "timestamp" => (now + 3.weeks).beginning_of_week, "count"=>1, "min"=>10, "max"=>10, "sum"=>10, "avg"=>10})
- expect(stats).to include({ "timestamp" => (now + 6.weeks).beginning_of_week, "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17})
+ expect(stats).to include({ "timestamp" => (now + 6.weeks).beginning_of_week, "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17.5})
end
it "returns the expected results for a monthly metric" do
create_span(:months)
stats = metric.stats(now..(now + 7.months), :month)
expect(stats).to include({ "timestamp" => (now + 3.months), "count"=>1, "min"=>10, "max"=>10, "sum"=>10, "avg"=>10})
- expect(stats).to include({ "timestamp" => (now + 6.months), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17})
+ expect(stats).to include({ "timestamp" => (now + 6.months), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17.5})
end
it "returns the expected results for a yearly metric" do
create_span(:years)
stats = metric.stats(now..(now + 7.years), :year)
expect(stats).to include({ "timestamp" => (now + 3.years), "count"=>1, "min"=>10, "max"=>10, "sum"=>10, "avg"=>10})
- expect(stats).to include({ "timestamp" => (now + 6.years), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17})
+ expect(stats).to include({ "timestamp" => (now + 6.years), "count"=>2, "min"=>15, "max"=>20, "sum"=>35, "avg"=>17.5})
end
end
describe ".drop!" do