summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-03-18 01:00:56 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-03-20 18:27:08 +1100
commita497263d97229489dcc4341cc98ca3c75f116374 (patch)
tree8fdeb5589e4ba48aadb624c75448b4a23cd246e3 /spec/unit
parent3e954997f7688f0193010de776879d23545a8ca5 (diff)
downloadpuppet-a497263d97229489dcc4341cc98ca3c75f116374.tar.gz
puppet-a497263d97229489dcc4341cc98ca3c75f116374.tar.xz
puppet-a497263d97229489dcc4341cc98ca3c75f116374.zip
Adding explicit optional attribute to indirection requests
Previously, any option that had a setter was treated as an attribute, but now we're specifying the list of attributes settable via options. We also have a to_hash method that will take all of the options and all of those attributes and join them back into a hash. This method is used by the REST Handler module, since it uses the indirection request internally. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/indirector/request.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/unit/indirector/request.rb b/spec/unit/indirector/request.rb
index e2a871a5f..47ffc319c 100755
--- a/spec/unit/indirector/request.rb
+++ b/spec/unit/indirector/request.rb
@@ -80,6 +80,14 @@ describe Puppet::Indirector::Request do
Puppet::Indirector::Request.new(:ind, :method, :key, :foo => "bar").options.should be_instance_of(Hash)
end
+ it "should treat options other than :ip, :node, and :authenticated as options rather than attributes" do
+ Puppet::Indirector::Request.new(:ind, :method, :key, :server => "bar").options[:server].should == "bar"
+ end
+
+ it "should normalize options to use symbols as keys" do
+ Puppet::Indirector::Request.new(:ind, :method, :key, "foo" => "bar").options[:foo].should == "bar"
+ end
+
describe "and the request key is a URI" do
describe "and the URI is a 'file' URI" do
before do
@@ -216,6 +224,14 @@ describe Puppet::Indirector::Request do
Puppet::Indirector::Request.new(:myind, :find, "my key" ).environment.should equal(Puppet::Node::Environment.new)
end
+ it "should support converting its options to a hash" do
+ Puppet::Indirector::Request.new(:myind, :find, "my key" ).should respond_to(:to_hash)
+ end
+
+ it "should include all of its attributes when its options are converted to a hash" do
+ Puppet::Indirector::Request.new(:myind, :find, "my key", :node => 'foo').to_hash[:node].should == 'foo'
+ end
+
describe "when building a query string from its options" do
before do
@request = Puppet::Indirector::Request.new(:myind, :find, "my key")