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