Browse files

Test for supporting various conventions for array fields, e.g. "?a[]=…

…1&a[]=2" or "?a=1&a=2".
  • Loading branch information...
1 parent ad9ea7f commit 5df99d172a1e065d096830378800451129a88ef7 Jen-Mei Wu & Kurt Ruppel committed Jan 30, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 spec/unit/util/uri_spec.rb
View
23 spec/unit/util/uri_spec.rb
@@ -172,6 +172,29 @@
lambda { WebMock::Util::URI.normalize_uri(uri) }.should_not raise_error(ArgumentError)
end
+ context "with array parameters" do
+
+ it "should successfully handle array parameters" do
+ uri = 'http://www.example.com:80/path?a[]=b&a[]=c'
+ lambda { WebMock::Util::URI.normalize_uri(uri) }.should_not raise_error(ArgumentError)
+ end
+
+ context "in various formats" do
+ it "should be able to turn array parameters into a query string of the format ?a[]=b&a[]=c" do
+ uri_string = 'http://www.example.com:80/path?a[]=b&a[]=c'
+ uri = WebMock::Util::URI.normalize_uri(uri_string)
+ Addressable::URI.unencode(uri.query).should == "a[]=b&a[]=c"
+ end
+
+ it "should be able to turn array parameters into a query string of the format ?a=b&a=c" do
+ uri_string = 'http://www.example.com:80/path?a=b&a=c'
+ uri = WebMock::Util::URI.normalize_uri(uri_string)
+ Addressable::URI.unencode(uri.query).should == "a=b&a=c"
+ end
+ end
+
+ end
+
end
describe "stripping default port" do

0 comments on commit 5df99d1

Please sign in to comment.