fix Builder::Handler comparison to another Handler

This commit is contained in:
Mislav Marohnić 2011-05-13 10:24:56 -07:00
parent accd07fa20
commit f7e80bf4ce
2 changed files with 10 additions and 1 deletions

View File

@ -34,7 +34,9 @@ module Faraday
def inspect() @name end
def ==(other)
if other.respond_to? :name
if other.is_a? Handler
self.name == other.name
elsif other.respond_to? :name
klass == other
else
@name == other.to_s

View File

@ -87,6 +87,13 @@ class MiddlewareStackTest < Faraday::TestCase
assert !duped_connection.builder.locked?
end
def test_handler_comparison
build_stack Apple
assert_equal @builder.handlers.first, Apple
assert_equal @builder.handlers[0,1], [Apple]
assert_equal @builder.handlers.first, Faraday::Builder::Handler.new(Apple)
end
private
# make a stack with test adapter that reflects the order of middleware