require 'ganymed/sampler/gauge' require 'sampler/datasource_examples' describe Ganymed::Sampler::Gauge do include_context 'DataSource' subject { Ganymed::Sampler::Gauge.new(ticks) } let(:values) { 10.times.collect { rand } } it_behaves_like Ganymed::Sampler::DataSource describe "#flush" do before(:each) do values.each do |value| subject.feed(ns, origin, nil, value) end end it "should call each" do subject.should_receive(:each).with(1).once subject.flush(1) end it "should yield all values" do expect { |b| subject.flush(1, &b) }.to yield_with_args(ns, origin, values) end end describe "#feed" do it "should add fed samples" do subject.should_receive(:add).with(ns, origin, value) subject.feed(ns, origin, nil, value) end end end