Sha256: d26644508050fffdaf850a1ea7db35d5e8ed4927da1d99363a07066cb27daeba
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe Dboard::Collector, "register_source" do before do Dboard::Collector.instance.sources.clear end it "can register a source" do new_relic = mock new_relic.stub!(:update_interval).and_return(5) Dboard::Collector.register_source :new_relic, new_relic Dboard::Collector.instance.sources.should == { :new_relic => new_relic } end it "can register an after update callback" do new_relic = mock new_relic.stub!(:fetch).and_return({ :db => "100%" }) callback = mock Dboard::Collector.register_after_update_callback callback callback.should_receive(:call) Dboard::Publisher.stub!(:publish) Dboard::Collector.instance.update_source(:new_relic, new_relic) # since it is a singleton, and this callbacks leaks into the other tests Dboard::Collector.register_after_update_callback(lambda {}) end end describe Dboard::Collector, "update_source" do before do Dboard::Collector.instance.sources.clear end it "should collect and publish data from sources" do new_relic = mock new_relic.stub!(:fetch).and_return({ :db => "100%" }) Dboard::Publisher.should_receive(:publish).with(:new_relic, { :db => "100%" }) Dboard::Collector.instance.update_source(:new_relic, new_relic) end it "should print out debugging info" do new_relic = mock new_relic.stub!(:fetch).and_raise(Exception.new("some error")) Dboard::Collector.instance.should_receive(:puts).twice Dboard::Collector.instance.update_source(:new_relic, new_relic) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dboard-1.0.5 | spec/collector_spec.rb |
dboard-1.0.4 | spec/collector_spec.rb |