Browse files

Updated Extensions to have string#tap and added test case

Signed-off-by: designwaves <brian.bokor@designwaves.com>
  • Loading branch information...
1 parent 2b2c980 commit adfc3c982113db49ded5c079b0031dbea381a8cc @bokor bokor committed Jan 16, 2012
Showing with 15 additions and 0 deletions.
  1. +5 −0 lib/aws/s3/extensions.rb
  2. +10 −0 test/extensions_test.rb
View
5 lib/aws/s3/extensions.rb
@@ -38,6 +38,11 @@ def previous!
end
end
+ def tap
+ yield(self)
+ self
+ end unless ''.respond_to?(:tap)
+
def previous
dup.previous!
end
View
10 test/extensions_test.rb
@@ -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

0 comments on commit adfc3c9

Please sign in to comment.