spec/lib/tabs/metrics/value/stats_spec.rb in tabs-0.8.0 vs spec/lib/tabs/metrics/value/stats_spec.rb in tabs-0.8.1
- old
+ new
@@ -36,6 +36,26 @@
it "avg returns the average for the entire set" do
expect(stats.avg).to eq 16.76
end
+ it "avg returns 0 if set is empty" do
+ stats = Tabs::Metrics::Value::Stats.new(period, resolution, [])
+ expect(stats.avg).to be_zero
+ end
+
+ context "override decimal precision" do
+ before do
+ @precision = Tabs.config.decimal_precision
+ Tabs.config.decimal_precision = 1
+ end
+
+ after do
+ Tabs.config.decimal_precision = @precision
+ end
+
+ it "allows you to override decimal precision" do
+ expect(stats.avg).to eq 16.8
+ end
+ end
+
end