Sha256: 4fd2c3e56459c36351e7990f1347550dbf53f5c834b6ee70ceca88f5d1c08533

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require 'ronin/formatting/http'

require 'spec_helper'

describe String do
  it "should provide String#uri_encode" do
    String.method_defined?(:uri_encode).should == true
  end

  it "should provide String#uri_decode" do
    String.method_defined?(:uri_decode).should == true
  end

  it "should provide String#uri_escape" do
    String.method_defined?(:uri_escape).should == true
  end

  it "should provide String#uri_unescape" do
    String.method_defined?(:uri_unescape).should == true
  end

  it "should provide String#format_http" do
    String.method_defined?(:format_http).should == true
  end

  describe "uri_encode" do
    before(:all) do
      @uri_unencoded = "mod % 3"
      @uri_encoded = "mod%20%25%203"
    end

    it "should URI encode itself" do
      @uri_unencoded.uri_encode.should == @uri_encoded
    end
  end

  describe "uri_decode" do
    before(:all) do
      @uri_unencoded = "mod % 3"
      @uri_encoded = "mod%20%25%203"
    end

    it "should URI decode itself" do
      @uri_encoded.uri_decode.should == @uri_unencoded
    end
  end

  describe "uri_escape" do
    before(:all) do
      @uri_unescaped = "x + y"
      @uri_escaped = "x+%2B+y"
    end

    it "should URI escape itself" do
      @uri_unescaped.uri_escape.should == @uri_escaped
    end
  end

  describe "uri_unescape" do
    before(:all) do
      @uri_unescaped = "x + y"
      @uri_escaped = "x+%2B+y"
    end

    it "should URI unescape itself" do
      @uri_escaped.uri_unescape.should == @uri_unescaped
    end
  end

  describe "format_http" do
    before(:all) do
      @uri_unencoded = "mod % 3"
      @uri_http_encoded = "%6d%6f%64%20%25%20%33"
    end

    it "should format each byte of the String" do
      @uri_unencoded.format_http.should == @uri_http_encoded
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-0.3.0 spec/formatting/http/string_spec.rb
ronin-0.2.4 spec/formatting/http/string_spec.rb