Sha256: e900a156e8146611df822a4dfedfc6183db4db8d37dd6b4b8d7832975d8f7781

Contents?: true

Size: 753 Bytes

Versions: 31

Compression:

Stored size: 753 Bytes

Contents

require 'spec_helper'

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

  describe "#event" do
    it "should count unique values" do
      expect{ sensor.event(:first) }.to change{sensor.value}.to(1)
      expect{ sensor.event(:first) }.not_to change{sensor.value}
      expect{ sensor.event(:second) }.to change{sensor.value}.from(1).to(2)
    end
  end

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

    it "should return count of unique values" do
      data = (1..100).map {rand(200)}
      data.each {|e| sensor.event(e)}
      sensor.value.should == data.uniq.count
    end
  end

end

Version data entries

31 entries across 31 versions & 3 rubygems

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