mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-09 12:47:50 +00:00
- a second attempt to make test_helper compatible with 1.8.x versions of Ruby
This commit is contained in:
+7
-2
@@ -15,8 +15,13 @@ end
|
||||
|
||||
def create_stub(funcs)
|
||||
stub = Class.new
|
||||
funcs.each_pair do |k,v|
|
||||
stub.define_singleton_method(k) {|*unused| return v }
|
||||
if (RUBY_VERSION.split('.')[0].to_i >= 2)
|
||||
funcs.each_pair {|k,v| stub.define_singleton_method(k) {|unused=nil| return v } }
|
||||
else
|
||||
blob = "class << stub\n"
|
||||
funcs.each_pair {|k,v| blob += "def #{k.to_s}(unused=nil)\n #{v.inspect}\nend\n" }
|
||||
blob += "end"
|
||||
eval blob
|
||||
end
|
||||
stub
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user