开发者

Rspec2: Mock class methods, but not all

开发者 https://www.devze.com 2023-02-14 02:34 出处:网络
I\'ve wrote aclass method, which calls other class methods of the sa开发者_运维知识库me class.

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

精彩评论

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