Sha256: d6b5dbd97d732f16a4b0a9c2768d2221e3195445df441c457071cb6e9f26acd8

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Typhoeus::Utils do
  # Taken from Rack 1.2.1
  describe "#escape" do
    it "should escape correctly" do
      Typhoeus::Utils.escape("fo<o>bar").should == "fo%3Co%3Ebar"
      Typhoeus::Utils.escape("a space").should == "a+space"
      Typhoeus::Utils.escape("q1!2\"'w$5&7/z8)?\\").
        should == "q1%212%22%27w%245%267%2Fz8%29%3F%5C"
    end

    it "should escape 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
      Typhoeus::Utils.escape(matz_name).should == '%E3%81%BE%E3%81%A4%E3%82%82%E3%81%A8'
      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
      Typhoeus::Utils.escape(matz_name_sep).should == '%E3%81%BE%E3%81%A4+%E3%82%82%E3%81%A8'
    end
  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
marnen-typhoeus-0.3.7 spec/typhoeus/utils_spec.rb
marnen-typhoeus-0.3.6 spec/typhoeus/utils_spec.rb
marnen-typhoeus-0.3.5 spec/typhoeus/utils_spec.rb
marnen-typhoeus-0.3.4 spec/typhoeus/utils_spec.rb
typhoeus-0.3.3 spec/typhoeus/utils_spec.rb
typhoeus-0.3.2 spec/typhoeus/utils_spec.rb
xenda-typhoeus-0.2.4 spec/typhoeus/utils_spec.rb
typhoeus-0.2.4 spec/typhoeus/utils_spec.rb
typhoeus-0.2.3 spec/typhoeus/utils_spec.rb
arachni-typhoeus-0.2.0.2 spec/typhoeus/utils_spec.rb
typhoeus-0.2.2 spec/typhoeus/utils_spec.rb
arachni-typhoeus-0.2.0.1 spec/typhoeus/utils_spec.rb
arachni-typhoeus-0.2.0 spec/typhoeus/utils_spec.rb
typhoeus-0.2.1 spec/typhoeus/utils_spec.rb