On Thu, Oct 23, 2008 at 7:49 AM, Bastien <[EMAIL PROTECTED]> wrote: > I m already specing the "generate_reports" methods with a mock on > "sub_total", but I would also like to spec that method. I've put this > method into protected because it doesn't make sens to call it from > outside this class. But you're arguing that I should put that method > into a lib ? I m not sure it would make sense as this method is very > specific to that class, and would actually be easy to spec. Except > that it's not possible to call a protected method from a spec as far > as I know, correct me if I m wrong. (I maybe didn't explain my problem > well in the first place)
If you're somehow mocking the sub_total method while specing the generate_reports method, don't do that. Don't stub/mock the thing that you're specing, only stub/mock its collaborators, i.e., its dependencies. I would either verify via generate_reports that the sub totals on the report are correct, or I'd factor out something like a ReportGenerator class and spec it. Then, I'd stub/mock out the ReportGenerator in the specs for the Survey class. Regards, Craig
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users