spec/lib/data_spec.rb in zabbix-ruby-client-0.0.20 vs spec/lib/data_spec.rb in zabbix-ruby-client-0.0.21

- old
+ new

@@ -31,31 +31,31 @@ @data.run_plugin("sample") expect(@data.instance_variable_get(:@items)).to eq items end it "logs an error when plugin is not found" do - ZabbixRubyClient::Log.stub(:error).with("Plugin unknown_plugin not found.") + allow(ZabbixRubyClient::Runner).to receive(:error).with("Plugin unknown_plugin not found.") @data.run_plugin("unknown_plugin") end it "runs a plugin that only has discovery" do discovery = { "sample.discover" => [["{\"{#SAMPLE}\": \"sample_arg\"}" ]]} @data.run_plugin("sample_discover", 'sample_arg') expect(@data.instance_variable_get(:@discover)).to eq discovery end it "ignores buggy plugins" do - expect(@data.run_plugin("sample_buggy")).to be_true + expect(@data.run_plugin("sample_buggy")).to be_truthy end it "logs buggy plugins" do - ZabbixRubyClient::Log.stub(:fatal).with("Oops") - ZabbixRubyClient::Log.stub(:fatal).with("Exception") + allow(ZabbixRubyClient::Log).to receive(:fatal).with("Oops") + allow(ZabbixRubyClient::Log).to receive(:fatal).with("Exception") @data.run_plugin("sample_buggy") end it "merges collected and discovered data" do - Time.stub(:now).and_return("123456789") + allow(Time).to receive(:now).and_return("123456789") @data.run_plugin("sample") @data.run_plugin("sample_discover") result = ["host sample.discover 123456789 { \"data\": [ {\"{#SAMPLE}\": \"\"} ] }", "localhost sample[foo] 123456789 42"] expect(@data.merge).to eq result