spec/lib/tabs/metrics/value_spec.rb in tabs-0.6.3 vs spec/lib/tabs/metrics/value_spec.rb in tabs-0.7.0

- old
+ new

@@ -7,16 +7,24 @@ let(:metric) { Tabs.create_metric("foo", "value") } let(:now) { Time.utc(2000, 1, 1, 0, 0) } describe ".record" do + before { Timecop.freeze(now) } + it "sets the expected values for the period" do - Timecop.freeze(now) 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({ time => {"count"=>2, "min"=>17, "max"=>42, "sum"=>59, "avg"=>29} }) + 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) + stats = metric.stats(((now - 3.hours)..now), :hour) + expect(stats).to include({ time => {"count"=>1, "min"=>42, "max"=>42, "sum"=>42, "avg"=>42} }) end end describe ".stats" do