开发者

Rspec2: Mock class methods, but not all

I've wrote a class method, which calls other class methods of the sa开发者_运维知识库me class.

class Statistic
  def self.do_something
    #...
  end

  def self.update_statistic
    Statistic.do_something
  end
end

How do I test, that update_statistic calls do_something?

I use Rails 3 & rspec 2.


You should be able to set an expectation on do_something and then call update_statistic directly.

Statistic.should_receive(:do_something)
Statistic.update_statistic
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜