THRIFT-1645: Replace Object#tee with more conventional Object#tap in specs
Client: rb
Patch: Nathan Beyer
The spec_helper.rb defines an Object#tee method, which is functionally equivalent to Object#tap. Object#tap was added to Ruby 1.9 and to 1.8.7.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1392509 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/spec_helper.rb b/lib/rb/spec/spec_helper.rb
index 9701c7c..8664b66 100644
--- a/lib/rb/spec/spec_helper.rb
+++ b/lib/rb/spec/spec_helper.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -28,11 +29,13 @@
require 'thrift'
-class Object
- # tee is a useful method, so let's let our tests have it
- def tee(&block)
- block.call(self)
- self
+unless Object.method_defined? :tap
+ # if Object#tap isn't defined, then add it; this should only happen in Ruby < 1.8.7
+ class Object
+ def tap(&block)
+ block.call(self)
+ self
+ end
end
end