Sha256: b17fde072a724a21f9880767dd35372f270dfa9409d9c0a67b23d92ac95b057c

Contents?: true

Size: 1.08 KB

Versions: 27

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe PulseMeter::Sensor::HashedIndicator do
  let(:name){ :some_counter }
  let(:sensor){ described_class.new(name) }
  let(:redis){ PulseMeter.redis }

  describe "#event" do
    it "should set sensor value to passed value" do
      expect{ sensor.event("foo" => 10.4) }.to change{ sensor.value["foo"] }.from(0).to(10.4)
      expect{ sensor.event("foo" => 15.1) }.to change{ sensor.value["foo"] }.from(10.4).to(15.1)
    end

    it "should take multiple events" do
      data = {"foo" => 1.1, "boo" => 2.2}
      sensor.event(data)
      sensor.value.should == data
    end
  end

  describe "#value_key" do
    it "should be composed of sensor name and pulse_meter:value: prefix" do
      sensor.value_key.should == "pulse_meter:value:#{name}"
    end
  end

  describe "#value" do
    it "should have initial value 0" do
      sensor.value["foo"].should == 0
    end

    it "should store redis hash by value_key" do
      sensor.event({"foo" => 1})
      sensor.value.should == {"foo" => 1}
      redis.hgetall(sensor.value_key).should == {"foo" => "1.0"}
    end
  end

end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
pulse_meter_core-0.5.3 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse_meter_core-0.5.2 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse_meter_core-0.5.1 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse_meter_core-0.5.0 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse_meter_core-0.4.13 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.9 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.8 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.7 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.6 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.5 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.4 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.3 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.2 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.1 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.4.0 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.3.2 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.3.1 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.3.0 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.2.11 spec/pulse_meter/sensor/hashed_indicator_spec.rb
pulse-meter-0.2.10 spec/pulse_meter/sensor/hashed_indicator_spec.rb