1
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
4

0 回答 0