I have a recursive class-level method that I'd like to spec. the logic of it essentially does something like this:
def self.mymethod(inputs) If x = <find something in db based on inputs> x.do_something else <add something to db based on inputs> mymethod(inputs) end end I want to find a way to write a spec for this method that does both of these things: (1) stub out the do_something method (that method has its own specs) (2) not stub out the logic in the else statement, (there is some complex logic in there involving sql queries on multiple tables and i explicitly want to make it touch the database so that I can examine the state of the database after the method is run in my spec. a lot of complex stubs would be required to do this while also having the spec that is actually useful) any thoughts on how to accomplish this? two approaches that would make sense but don't seem to be possible as far as i know are: (A) stub out the do_something method for any instance of the class (i can't stub it out for a particular record because the records don't exist at the time of calling the method and I'm not stubbing the creation process) (B) stub out "mymethod" only for the second time it is called (obviously i can't stub the method out entirely since that's the method i'm testing) thanks..
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users