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
精彩评论