diff --git a/spec/addressable/uri_spec.rb b/spec/addressable/uri_spec.rb index 6aecabcb..a2ed1071 100644 --- a/spec/addressable/uri_spec.rb +++ b/spec/addressable/uri_spec.rb @@ -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 @@ -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(