Sha256: 55bbb180ed6a1a8f01417f25f973a1a2dd2d4c227098c5e5780287bd8b5b263b

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

require "spec_helper"

describe Aitch::URI do
  it "returns default path" do
    expect(Aitch::URI.new("http://example.org").path).to eql("/")
  end

  it "returns defined path" do
    expect(Aitch::URI.new("http://example.org/some/path").path).to eql("/some/path")
  end

  it "returns fragment" do
    expect(Aitch::URI.new("http://example.org/#top").fragment).to eql("#top")
  end

  it "returns query string" do
    expect(Aitch::URI.new("http://example.org/?a=1&b=2").query).to eql("?a=1&b=2")
  end

  it "converts data into query string" do
    expect(Aitch::URI.new("http://example.org", a: 1, b: 2).query).to eql("?a=1&b=2")
  end

  it "merges data into query string" do
    expect(Aitch::URI.new("http://example.org/?a=1&b=2", c: 3).query).to eql("?a=1&b=2&c=3")
  end

  it "ignores data when request has body" do
    expect(Aitch::URI.new("http://example.org/", {c: 3}, true).query).to eql(nil)
  end

  it "returns request uri" do
    uri = Aitch::URI.new("http://example.org/some/path?a=1&b=2#hello", c: 3)
    expect(uri.request_uri).to eql("/some/path?a=1&b=2&c=3#hello")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aitch-0.4.1 spec/aitch/uri_spec.rb
aitch-0.4.0 spec/aitch/uri_spec.rb
aitch-0.3.0 spec/aitch/uri_spec.rb
aitch-0.2.1 spec/aitch/uri_spec.rb
aitch-0.2.0 spec/aitch/uri_spec.rb
aitch-0.1.5 spec/aitch/uri_spec.rb
aitch-0.1.4 spec/aitch/uri_spec.rb
aitch-0.1.3 spec/aitch/uri_spec.rb
aitch-0.1.2 spec/aitch/uri_spec.rb