Displaying 1 result from an estimated 1 matches for "do_something_expensive".
2006 Jun 15
3
How to mock a model method for unit tests?
I have a model class, say, model.rb, and in the normal course of things
it creates an instance of another class, say utility.rb (also in the
models directory).
class Utility
def initialize(obj)
# do stuff...
end
def do_something_expensive
# lots of stuff here
end
end
During testing, I want to mock out do_something_expensive because it''s
not important for the tests, but only during development. So I went to
the tests\mocks folder and added a file called utility.rb with only
this:
# this is the mock file
class Ut...