Skip to content

Commit

Permalink
Adding tests for origin assignment errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
sporkmonger committed Nov 4, 2016
1 parent 4c2a62f commit 9e45633
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion spec/addressable/uri_spec.rb
Expand Up @@ -1803,14 +1803,26 @@ def to_s
end

it "should have the same hash as http://EXAMPLE.com after assignment" do
@uri.host = "EXAMPLE.com"
@uri.origin = "http://EXAMPLE.com"
expect(@uri.hash).to eq(Addressable::URI.parse("http://EXAMPLE.com").hash)
end

it "should have a different hash from http://EXAMPLE.com" do
expect(@uri.hash).not_to eq(Addressable::URI.parse("http://EXAMPLE.com").hash)
end

it "should not allow origin assignment without scheme" do
expect(lambda do
@uri.origin = "example.com"
end).to raise_error(Addressable::URI::InvalidURIError)
end

it "should not allow origin assignment without host" do
expect(lambda do
@uri.origin = "http://"
end).to raise_error(Addressable::URI::InvalidURIError)
end

# Section 6.2.3 of RFC 3986
it "should be equivalent to http://example.com/" do
expect(@uri).to eq(Addressable::URI.parse("http://example.com/"))
Expand Down

0 comments on commit 9e45633

Please sign in to comment.