10 @ddl.stubs(:dataquery_interface).returns({:output => {'rspec' => {}}})
11 @ddl.stubs(:meta).returns({:timeout => 1})
14 describe "#initialize" do
15 it "should set the plugin name, ddl and timeout and call the startup hook" do
16 DDL.stubs(:new).returns(@ddl)
17 Base.any_instance.expects(:startup_hook).once
19 plugin.name.should == "base"
20 plugin.timeout.should == 1
21 plugin.result.class.should == Result
27 DDL.stubs(:new).returns(@ddl)
31 it "should validate the request" do
32 @plugin.expects(:ddl_validate).with("hello world").returns(true)
33 @plugin.stubs(:query_data)
34 @plugin.lookup("hello world")
37 it "should query the plugin" do
38 @plugin.stubs(:ddl_validate)
39 @plugin.expects(:query_data).with("hello world")
40 @plugin.lookup("hello world").class.should == Result
43 it "should raise MsgTTLExpired errors for Timeout errors" do
44 @plugin.stubs(:ddl_validate)
45 @plugin.expects(:query_data).raises(Timeout::Error)
47 msg = "Data plugin base timed out on query 'hello world'"
48 Log.expects(:error).with(msg)
49 expect { @plugin.lookup("hello world") }.to raise_error(msg)
54 it "should create a new method" do
55 class Rspec_data<Base; end
56 Rspec_data.query { "rspec test" }
58 DDL.stubs(:new).returns(@ddl)
61 data.query_data.should == "rspec test"
65 describe "#ddl_validate" do
66 it "should validate the request using the Data class" do
67 DDL.stubs(:new).returns(@ddl)
69 Data.expects(:ddl_validate).with(@ddl, "rspec")
70 plugin.ddl_validate("rspec")
74 describe "#activate_when" do
75 it "should create a new activate? method" do
76 class Rspec_data<Base;end
78 Rspec_data.activate_when { raise "rspec" }
79 DDL.stubs(:new).returns(@ddl)
80 expect { Rspec_data.activate? }.to raise_error("rspec")
84 describe "#activate?" do
85 it "should default to true" do
86 Base.activate?.should == true