9 Cache.delete!(:ddl) rescue nil
10 @ddl = DDL.new("rspec", :data, false)
11 @ddl.metadata(:name => "name", :description => "description", :author => "author", :license => "license", :version => "version", :url => "url", :timeout => "timeout")
15 it "should only allow 'query' as input for data plugins" do
16 ddl = DDL.new("rspec", :data, false)
17 ddl.dataquery(:description => "rspec")
18 ddl.instance_variable_set("@current_entity", :query)
19 ddl.instance_variable_set("@plugintype", :data)
21 expect { ddl.input(:rspec, {}) }.to raise_error("The only valid input name for a data query is 'query'")
25 describe "#dataquery_interface" do
26 it "should return the correct data" do
27 input = {:prompt => "Matcher", :description => "Augeas Matcher", :type => :string, :validation => /.+/, :maxlength => 0}
28 output = {:description=>"rspec", :display_as=>"rspec", :default => nil}
30 @ddl.instance_variable_set("@plugintype", :data)
31 @ddl.dataquery(:description => "rspec") do
32 @ddl.output :rspec, output
33 @ddl.input :query, input
36 @ddl.dataquery_interface.should == {:description => "rspec",
37 :input => {:query => input.merge(:optional => nil, :default => nil)},
38 :output => {:rspec => output}}
42 describe "#dataquery" do
43 it "should ensure a description is set" do
44 expect { @ddl.dataquery({}) }.to raise_error("Data queries need a :description")
47 it "should ensure only one definition" do
48 @ddl.dataquery(:description => "rspec")
50 expect { @ddl.dataquery(:description => "rspec") }.to raise_error("Data queries can only have one definition")
53 it "should create the default structure" do
54 @ddl.dataquery(:description => "rspec")
55 @ddl.instance_variable_set("@plugintype", :data)
56 @ddl.dataquery_interface.should == {:description => "rspec", :input => {}, :output => {}}
59 it "should call the block if given" do
60 @ddl.dataquery(:description => "rspec") { @ddl.instance_variable_get("@current_entity").should == :data }