Sha256: b1cbd35973ac60c9fd19b12ae5911c1bb3b74b7109ae38dc553c0b218c087d98

Contents?: true

Size: 1.29 KB

Versions: 15

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Github::Utils::Url do

  it 'escapes correctly' do
    described_class.escape('<html>').should eql '%3Chtml%3E'
    described_class.escape('a space').should eql 'a+space'
    described_class.escape('\\/?}!@#$%^&*()').should eql '%5C%2F%3F%7D%21%40%23%24%25%5E%26%2A%28%29'
  end

  it 'unescapes correctly' do
    described_class.unescape('%3Chtml%3E').should eql '<html>'
    described_class.unescape('a+space').should eql 'a space'
    described_class.unescape('%5C%2F%3F%7D%21%40%23%24%25%5E%26%2A%28%29').should eql '\\/?}!@#$%^&*()'
  end

  context 'parses query strings correctly' do
    it { described_class.parse_query("a=b").should eq 'a' => 'b' }
    it { described_class.parse_query("a=b&a=c").should eq 'a' => ['b','c'] }
    it { described_class.parse_query("a=b&c=d").should eq 'a' => 'b', 'c' => 'd' }
    it { described_class.parse_query("a+b=%28c%29").should eq 'a b' => '(c)' }
  end

  context 'parse_query_for_param' do
    it 'returns nil if cannot find parameter' do
      described_class.parse_query_for_param("param1=a;param2=b", 'param3').
        should be_nil
    end

    it 'returns value for given parameter name' do
      described_class.parse_query_for_param("param1=a;param2=b", 'param1').
        should eq 'a'
    end
  end

end # Github::Utils::Url

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
github_api-0.5.1 spec/github/utils/url_spec.rb
github_api-0.5.0 spec/github/utils/url_spec.rb
github_api-0.5.0.rc1 spec/github/utils/url_spec.rb
github_api-0.4.11 spec/github/utils/url_spec.rb
github_api-0.4.10 spec/github/utils/url_spec.rb
github_api-0.4.9 spec/github/utils/url_spec.rb
github_api-0.4.8 spec/github/utils/url_spec.rb
github_api-0.4.7 spec/github/utils/url_spec.rb
github_api-0.4.6 spec/github/utils/url_spec.rb
github_api-0.4.5 spec/github/utils/url_spec.rb
github_api-0.4.4 spec/github/utils/url_spec.rb
github_api-0.4.3 spec/github/utils/url_spec.rb
github_api-0.4.2 spec/github/utils/url_spec.rb
github_api-0.4.1 spec/github/utils/url_spec.rb
github_api-0.4.0 spec/github/utils/url_spec.rb