class Foo
def self.with_context
# some preprocessing stuff
yield
# some postprocessing stuff
end
def self.bar
with_context do
#some stuff here
end
end
end
如何测试Foo.bar方法是在Foo.with_context?
中运行的它应该传递上面的例子。
但是在下面的例子中应该失败:
class Foo
def self.with_context
# some preprocessing stuff
yield
# some postprocessing stuff
end
def self.bar
#some stuff here ( not within the with_context block - FATAL)
end
end