plugins/observed-gauge/spec/gauge_spec.rb in observed-0.1.1 vs plugins/observed-gauge/spec/gauge_spec.rb in observed-0.2.0.rc1

- old
+ new

@@ -1,8 +1,9 @@ require 'spec_helper' require 'observed/gauge' +require 'observed/system' shared_examples_for 'the observed-gauge plugin' do subject { described_class.new @@ -18,18 +19,17 @@ expect(subject.match('test.foo')).to be_true end it 'reports data with averaged values' do subject.prepare_rrd(start: t - 120, rrd: rrd) - system.expects(:report).with(tag, expected_data.freeze).once - expect { subject.report('test.foo', t - 120, data) }.to_not raise_error - expect { subject.report('test.foo', t - 60, data) }.to_not raise_error - expect { subject.report('test.foo', t, data) }.to_not raise_error + expect(subject.translate(data, {tag: 'test.foo', time: t - 120})).to be_nil + expect(subject.translate(data, {tag: 'test.foo', time: t - 60})).to be_nil + expect(subject.translate(data, {tag: 'test.foo', time: t})).to eq(expected_data) end it 'creates rrd files automatically on first report' do - expect { subject.report('test.foo', t, data) }.to_not raise_error + expect { subject.translate(data, {tag: 'test.foo', time: t}) }.to_not raise_error expect { File.exist? rrd }.to be_true end end @@ -62,11 +62,11 @@ let(:t) { Time.now } let(:system) { - sys = mock('system') + sys = Observed::System.new sys.stubs(:now).returns(t) sys } @@ -115,10 +115,10 @@ let(:t) { Time.now } it 'raise an error' do - expect { subject.report('test.foo', t, data) }.to raise_error(/Unexpected type of key_path met/) + expect { subject.translate(data, {tag: 'test.foo', time: t}) }.to raise_error(/Unexpected type of key_path met/) end end context 'with a correct key path' do