spec/uri/unescape_spec.rb in escape_utils-0.2.2 vs spec/uri/unescape_spec.rb in escape_utils-0.2.3

- old
+ new

@@ -37,29 +37,20 @@ EscapeUtils.unescape_uri("q1!2%22'w$5&7/z8)?%5C").should eql("q1!2\"'w$5&7/z8)?\\") end # NOTE: from Rack's test suite it "should unescape correctly for multibyte characters" do - matz_name = "\xE3\x81\xBE\xE3\x81\xA4\xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0] # Matsumoto - matz_name.force_encoding("UTF-8") if matz_name.respond_to? :force_encoding + matz_name = "\xE3\x81\xBE\xE3\x81\xA4\xE3\x82\x82\xE3\x81\xA8" # Matsumoto EscapeUtils.unescape_uri('%E3%81%BE%E3%81%A4%E3%82%82%E3%81%A8').should eql(matz_name) - matz_name_sep = "\xE3\x81\xBE\xE3\x81\xA4 \xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0] # Matsu moto - matz_name_sep.force_encoding("UTF-8") if matz_name_sep.respond_to? :force_encoding + matz_name_sep = "\xE3\x81\xBE\xE3\x81\xA4 \xE3\x82\x82\xE3\x81\xA8" # Matsu moto 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 the original string's encoding if Encoding.default_internal is nil" do - Encoding.default_internal = nil - str = "http%3A%2F%2Fwww.homerun.com%2F" - str = str.encode('us-ascii') + it "return value should be in original string's encoding" do + str = "http%3A%2F%2Fwww.homerun.com%2F".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) - Encoding.default_internal = Encoding.find('us-ascii') - EscapeUtils.unescape_uri("http%3A%2F%2Fwww.homerun.com%2F").encoding.should eql(Encoding.default_internal) + str = "http%3A%2F%2Fwww.homerun.com%2F".encode('utf-8') + EscapeUtils.unescape_uri(str).encoding.should eql(Encoding.find('utf-8')) end end end \ No newline at end of file