spec/unit/ddl/agentddl_spec.rb in mcollective-client-2.2.4 vs spec/unit/ddl/agentddl_spec.rb in mcollective-client-2.4.0

- old
+ new

@@ -15,10 +15,40 @@ it "should validate that an :optional property is set" do expect { @ddl.input(:x, {:y => 1}) }.to raise_error("Input needs a :optional property") end end + describe "#set_default_input_arguments" do + before do + @ddl.action(:test, :description => "rspec") + @ddl.instance_variable_set("@current_entity", :test) + + @ddl.input(:optional, :prompt => "prompt", :description => "descr", + :type => :string, :optional => true, :validation => "", + :maxlength => 1, :default => "default") + @ddl.input(:required, :prompt => "prompt", :description => "descr", + :type => :string, :optional => false, :validation => "", + :maxlength => 1, :default => "default") + end + + it "should correctly add default arguments to required inputs" do + args = {} + + @ddl.set_default_input_arguments(:test, args) + + args.should == {:required => "default"} + end + + it "should not override any existing arguments" do + args = {:required => "specified"} + + @ddl.set_default_input_arguments(:test, args) + + args.should == {:required => "specified"} + end + end + describe "#validate_rpc_request" do it "should ensure the action is known" do @ddl.action(:test, :description => "rspec") expect { @@ -35,9 +65,11 @@ :type => :string, :optional => true, :validation => "", :maxlength => 1) @ddl.input(:required, :prompt => "prompt", :description => "descr", :type => :string, :optional => false, :validation => "", :maxlength => 1) + + @ddl.stubs(:validate_input_argument).returns(true) expect { @ddl.validate_rpc_request(:test, {}) }.to raise_error("Action test needs a required argument")