spec/uri/unescape_spec.rb in escape_utils-0.1.9 vs spec/uri/unescape_spec.rb in escape_utils-0.2.0

- old
+ new

@@ -9,10 +9,18 @@ it "should unescape a basic url" do EscapeUtils.unescape_uri("http%3A%2F%2Fwww.homerun.com%2F").should eql("http://www.homerun.com/") EscapeUtils.unescape_uri("http://www.homerun.com/").should eql("http://www.homerun.com/") end + it "should not be thrown by a standalone %" do + EscapeUtils.unescape_uri("%").should eql("%") + end + + it "should not be thrown by a trailing %" do + EscapeUtils.unescape_uri("http%").should eql("http%") + end + # NOTE: from Rack's test suite it "should unescape a url containing tags" do EscapeUtils.unescape_uri("fo%3Co%3Ebar").should eql("fo<o>bar") end @@ -38,12 +46,14 @@ matz_name_sep.force_encoding("UTF-8") if matz_name_sep.respond_to? :force_encoding EscapeUtils.unescape_uri('%E3%81%BE%E3%81%A4%20%E3%82%82%E3%81%A8').should eql(matz_name_sep) end if RUBY_VERSION =~ /^1.9/ - it "should default to utf-8 if Encoding.default_internal is nil" do + it "should default to the original string's encoding if Encoding.default_internal is nil" do Encoding.default_internal = nil - EscapeUtils.unescape_uri("http%3A%2F%2Fwww.homerun.com%2F").encoding.should eql(Encoding.find('utf-8')) + str = "http%3A%2F%2Fwww.homerun.com%2F" + str = str.encode('us-ascii') + EscapeUtils.unescape_uri(str).encoding.should eql(Encoding.find('us-ascii')) end it "should use Encoding.default_internal" do Encoding.default_internal = Encoding.find('utf-8') EscapeUtils.unescape_uri("http%3A%2F%2Fwww.homerun.com%2F").encoding.should eql(Encoding.default_internal) \ No newline at end of file