spec/helpers.rb in cross-stub-0.1.3.1 vs spec/helpers.rb in cross-stub-0.1.4
- old
+ new
@@ -10,16 +10,26 @@
class AnyClass
def self.say_world
'u say world'
end
+ class Inner
+ def self.say_world
+ 'u say world'
+ end
+ end
end
module AnyModule
def self.say_world
'u say world'
end
+ module Inner
+ def self.say_world
+ 'u say world'
+ end
+ end
end
module EchoClient
class << self
@@ -83,15 +93,16 @@
def receive_data(klass_and_method)
log "(1) EchoServer::EM#receive_data ... receives: #{klass_and_method}"
CrossStub.refresh(:file => $cache_file)
log "(2) EchoServer::EM#receive_data ... completes stubs refresh"
klass, method, *args = klass_and_method.split('.')
+ konst = klass.split(/::/).inject(Object) { |const_train, const| const_train.const_get(const) }
log "(3) EchoServer::EM#receive_data ... parses arguments to:",
" * klass ... #{klass}",
" * method ... #{method}",
" * args ... #{args.inspect}"
- value = args.empty? ? Object.const_get(klass).send(method) :
- Object.const_get(klass).send(method, *args) rescue $!.message
+ value = args.empty? ? konst.send(method) :
+ konst.send(method, *args) rescue $!.message
log "(4) EchoServer::EM#receive_data ... returns: #{value.inspect}"
send_data(Marshal.dump(value))
log "(5) EchoServer::EM#receive_data ... end"
end