Skip to content

Commit

Permalink
Test for supporting various conventions for array fields, e.g. "?a[]=…
Browse files Browse the repository at this point in the history
…1&a[]=2" or "?a=1&a=2".
  • Loading branch information
Jen-Mei Wu & Kurt Ruppel committed Jan 30, 2012
1 parent ad9ea7f commit 5df99d1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/unit/util/uri_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5df99d1

Please sign in to comment.