Skip to content

Commit

Permalink
Adding test to prove Addressable form encodes precisely as required b…
Browse files Browse the repository at this point in the history
…y OAuth 2.
  • Loading branch information
sporkmonger committed Jun 10, 2015
1 parent c0f296f commit 061f144
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/addressable/uri_spec.rb
Expand Up @@ -5426,6 +5426,7 @@ def to_str
end
end

# See https://tools.ietf.org/html/rfc6749#appendix-B
describe Addressable::URI, "when form encoding a non-Array object" do
it "should raise a TypeError for objects than cannot be converted" do
expect(lambda do
Expand All @@ -5434,6 +5435,22 @@ def to_str
end
end

describe Addressable::URI, "when form encoding the example value from OAuth 2" do
it "should result in correct values" do
expect(Addressable::URI.form_encode(
{"value" => " %&+£€"}
)).to eq("value=+%25%26%2B%C2%A3%E2%82%AC")
end
end

describe Addressable::URI, "when form unencoding the example value from OAuth 2" do
it "should result in correct values" do
expect(Addressable::URI.form_unencode(
"value=+%25%26%2B%C2%A3%E2%82%AC"
)).to eq([["value", " %&+£€"]])
end
end

describe Addressable::URI, "when form unencoding a string" do
it "should result in correct values" do
expect(Addressable::URI.form_unencode(
Expand Down

0 comments on commit 061f144

Please sign in to comment.