Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/uri/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def self.build(args)
end
end
else
component = self.class.component rescue ::URI::Generic::COMPONENT
component = self.component rescue ::URI::Generic::COMPONENT
raise ArgumentError,
"expected Array of or Hash of components of #{self.class} (#{component.join(', ')})"
"expected Array of or Hash of components of #{self} (#{component.join(', ')})"
end

tmp << nil
Expand Down
13 changes: 13 additions & 0 deletions test/uri/test_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,19 @@ def test_build
assert_equal("http://[::1]/bar/baz", u.to_s)
assert_equal("[::1]", u.host)
assert_equal("::1", u.hostname)

assert_raise_with_message(ArgumentError, /URI::Generic/) {
URI::Generic.build(nil)
}

c = Class.new(URI::Generic) do
def self.component; raise; end
end
expected = /\(#{URI::Generic::COMPONENT.join(', ')}\)/
message = "fallback to URI::Generic::COMPONENT if component raised"
assert_raise_with_message(ArgumentError, expected, message) {
c.build(nil)
}
end

def test_build2
Expand Down
Loading