spec/metrics_spec.rb in pliny-0.20.0 vs spec/metrics_spec.rb in pliny-0.20.1

- old
+ new

@@ -50,31 +50,53 @@ before do Timecop.freeze(Time.now) Pliny::Metrics.backends = [test_backend] end - it "measures a single key" do + it "measures a block's execution time with a single key" do metrics.measure(:foo) { } expect(test_backend).to have_received(:report_measures).once.with( "pliny.foo" => 0 ) end - it "measures a single key over a minute" do + it "measures a long block's execution time with a single key" do metrics.measure(:foo) do Timecop.travel(60) end expect(test_backend).to have_received(:report_measures) do |opts| assert(60 <= opts['pliny.foo'] && opts['pliny.foo'] <= 61) end end - it "measures multiple keys" do + it "measures a block's execution time with multiple keys" do metrics.measure(:foo, :bar) { } expect(test_backend).to have_received(:report_measures).once.with( "pliny.foo" => 0, "pliny.bar" => 0 + ) + end + + it "measures a given value for a single key without a block" do + metrics.measure(:baz, value: 3.14) + expect(test_backend).to have_received(:report_measures).once.with( + "pliny.baz" => 3.14 + ) + end + + it "measures a given value for multiple keys with a block" do + metrics.measure(:qux, :corge, value: 42) { } + expect(test_backend).to have_received(:report_measures).once.with( + "pliny.qux" => 42, + "pliny.corge" => 42 + ) + end + + it "measures a value of 0 when no key or block is provided" do + metrics.measure(:waldo) + expect(test_backend).to have_received(:report_measures).once.with( + "pliny.waldo" => 0 ) end end end