diff options
author | Luke Kanies <luke@madstop.com> | 2009-03-10 00:48:13 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2009-03-10 00:48:13 -0500 |
commit | d0fc2f5738a78c51128f6377c03fe42cf50371a0 (patch) | |
tree | 340ba2bb55f823b5cc180b9a4848456310aebda3 /spec | |
parent | 90afd48c39bc7bbb8e7afa81a49d2f814a787565 (diff) | |
download | puppet-d0fc2f5738a78c51128f6377c03fe42cf50371a0.tar.gz puppet-d0fc2f5738a78c51128f6377c03fe42cf50371a0.tar.xz puppet-d0fc2f5738a78c51128f6377c03fe42cf50371a0.zip |
Correctly handling numerical REST arguments
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/indirector/rest.rb | 10 | ||||
-rwxr-xr-x | spec/unit/network/http/mongrel/rest.rb | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb index 4fa30b20a..8ed50d300 100755 --- a/spec/unit/indirector/rest.rb +++ b/spec/unit/indirector/rest.rb @@ -194,6 +194,16 @@ describe Puppet::Indirector::REST do @searcher.query_string(@request).should == "?one=#{escaping}" end + it "should convert to a string all option values that are integers" do + @request.stubs(:options).returns(:one => 50) + @searcher.query_string(@request).should == "?one=50" + end + + it "should convert to a string all option values that are floating point numbers" do + @request.stubs(:options).returns(:one => 1.2) + @searcher.query_string(@request).should == "?one=1.2" + end + it "should convert to a string and URI-escape all option values that are symbols" do escaping = URI.escape("sym bol") @request.stubs(:options).returns(:one => :"sym bol") diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb index e72d4f540..c03698dbd 100755 --- a/spec/unit/network/http/mongrel/rest.rb +++ b/spec/unit/network/http/mongrel/rest.rb @@ -128,6 +128,18 @@ describe "Puppet::Network::HTTP::MongrelREST" do result[:foo].should be_false end + it "should convert integer arguments to Integers" do + @request.expects(:params).returns('QUERY_STRING' => 'foo=15') + result = @handler.params(@request) + result[:foo].should == 15 + end + + it "should convert floating point arguments to Floats" do + @request.expects(:params).returns('QUERY_STRING' => 'foo=1.5') + result = @handler.params(@request) + result[:foo].should == 1.5 + end + it "should YAML-load and URI-decode values that are YAML-encoded" do escaping = URI.escape(YAML.dump(%w{one two})) @request.expects(:params).returns('QUERY_STRING' => "foo=#{escaping}") |