diff --git a/lib/addressable/uri.rb b/lib/addressable/uri.rb index 40b80cf0..07c9aeb5 100644 --- a/lib/addressable/uri.rb +++ b/lib/addressable/uri.rb @@ -2382,7 +2382,7 @@ def to_hash # # @return [String] The URI object's state, as a String. def inspect - sprintf("#<%s:%#0x URI:%s>", URI.to_s, self.object_id, self.to_s) + sprintf("#<%s:%#0x URI:%s>", self.class.to_s, self.object_id, self.to_s) end ## diff --git a/spec/addressable/uri_spec.rb b/spec/addressable/uri_spec.rb index 26ee923d..07818490 100644 --- a/spec/addressable/uri_spec.rb +++ b/spec/addressable/uri_spec.rb @@ -1757,6 +1757,19 @@ def to_s expect(@uri.inspect).to include("%#0x" % @uri.object_id) end + context "when Addressable::URI has been sub-classed" do + class CustomURIClass < Addressable::URI + end + + before do + @uri = CustomURIClass.parse("http://example.com") + end + + it "when inspected, should have the sub-classes name" do + expect(@uri.inspect).to include("CustomURIClass") + end + end + it "should use the 'http' scheme" do expect(@uri.scheme).to eq("http") end