spec/gauge_spec.rb in fnordmetric-0.7.1 vs spec/gauge_spec.rb in fnordmetric-0.7.3

- old
+ new

@@ -26,29 +26,29 @@ gauge = FnordMetric::Gauge.new({:key_prefix => "foo", :key => "fnordgauge", :title => "Fnord Gauge"}) gauge.title.should == "Fnord Gauge" end it "should raise an error when initialize without key" do - lambda{ - FnordMetric::Gauge.new({:key_prefix => "foo"}) - }.should raise_error(KeyError) + lambda{ + FnordMetric::Gauge.new({:key_prefix => "foo"}) + }.should raise_error(key_error_klass) end it "should raise an error when initialize without key_prefix" do - lambda{ - FnordMetric::Gauge.new({:key => "foo"}) - }.should raise_error(KeyError) + lambda{ + FnordMetric::Gauge.new({:key => "foo"}) + }.should raise_error(key_error_klass) end it "should generate the correct key without append" do - gauge = FnordMetric::Gauge.new({:key_prefix => "fnordmetrics-myns", :key => "mygauge", :tick => 23}) - gauge.key.should == "fnordmetrics-myns-gauge-mygauge-23" + gauge = FnordMetric::Gauge.new({:key_prefix => "fnordmetrics-myns", :key => "mygauge", :tick => 23}) + gauge.key.should == "fnordmetrics-myns-gauge-mygauge-23" end it "should generate the correct key with append" do - gauge = FnordMetric::Gauge.new({:key_prefix => "fnordmetrics-myns", :key => "mygauge", :tick => 23}) - gauge.key(:fnord).should == "fnordmetrics-myns-gauge-mygauge-23-fnord" + gauge = FnordMetric::Gauge.new({:key_prefix => "fnordmetrics-myns", :key => "mygauge", :tick => 23}) + gauge.key(:fnord).should == "fnordmetrics-myns-gauge-mygauge-23-fnord" end describe "ticks" do it "should return the correct tick if configured" do @@ -91,11 +91,11 @@ end it "should retrieve a gauge value at the current tick" it "should call the value calculation block and return the result" do - @gauge.value_at(@now){ |v| v.to_i + 123 }.should == 177 + @gauge.value_at(@now){ |v, t| v.to_i + 123 }.should == 177 end it "should return the correct value_at per session" do @redis.hset(@gauge_key, "695280200", "76") @redis.set(@gauge_key+"-695280200-sessions-count", "23") @@ -164,11 +164,11 @@ 695280210 => (123.0/8.0) } end it "should receive gauge values with custom calculation for multiple ticks" do - @gauge.values_at([@now, @now+8]){ |val| + @gauge.values_at([@now, @now+8]){ |val, time| val.to_i + 30 }.should == { 695280200 => 84, 695280210 => 153 } @@ -228,10 +228,10 @@ @gauge.field_values_at(1323691200, :max_fields => 0).should be_a(Array) @gauge.field_values_at(1323691200, :max_fields => 0).length.should == 72 end it "should call the value calculation block and return the result" do - vals = @gauge.field_values_at(1323691200){ |v| v.to_i + 123 } + vals = @gauge.field_values_at(1323691200){ |v, t| v.to_i + 123 } vals.should be_a(Array) vals.length.should == 2 vals[0].should == ["uberfoo", 146] vals[1].should == ["fnordyblubb", 141] end \ No newline at end of file