Skip to content

Commit

Permalink
Updated Extensions to have string#tap and added test case
Browse files Browse the repository at this point in the history
Signed-off-by: designwaves <brian.bokor@designwaves.com>
  • Loading branch information
bokor committed Jan 17, 2012
1 parent 2b2c980 commit adfc3c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/aws/s3/extensions.rb
Expand Up @@ -38,6 +38,11 @@ def previous!
end
end

def tap
yield(self)
self
end unless ''.respond_to?(:tap)

def previous
dup.previous!
end
Expand Down
10 changes: 10 additions & 0 deletions test/extensions_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit adfc3c9

Please sign in to comment.