Fixed the deprecation of Object#returning for Object#tap on Connection.url_for #51

Merged
merged 2 commits into from May 29, 2012
Jump to file or symbol
Failed to load files and symbols.
+16 −1
Diff settings

Always

Just for now

View
@@ -63,7 +63,7 @@ def url_for(path, options = {})
path = self.class.prepare_path(path)
request = request_method(:get).new(path, {})
query_string = query_string_authentication(request, options)
- returning "#{protocol(options)}#{http.address}#{port_string}#{path}" do |url|
+ "#{protocol(options)}#{http.address}#{port_string}#{path}".tap do |url|
url << "?#{query_string}" if authenticate
end
end
View
@@ -38,6 +38,11 @@ def previous!
end
end
+ def tap
+ yield(self)
+ self
+ end unless ''.respond_to?(:tap)
+
def previous
dup.previous!
end
View
@@ -74,6 +74,16 @@ def test_remove_extended
assert "318597/620065/GTL_75\24300_A600_A610.zip".remove_extended.valid_utf8?
assert "318597/620065/GTL_75£00_A600_A610.zip".remove_extended.valid_utf8?
end
+
+ def test_tap
+ assert "http://google.com".tap do |url|
+ url << "/analtyics/"
+ end
+ assert "http://google.com".tap do |url|
+ url << "/download.zip"
+ end
+ end
+
end
class CoercibleStringTest < Test::Unit::TestCase