0

So, I have a controller nested within 2 others

here's an example route products/123/conditions/321/inventories/121

and the controllers are nested like this as well, so I'm trying to figure out what to stub out in my tests.

Product.should_receive(:find) does not get called. I'm wondering what will be the first thing called so I can begin to stub it.

I could find this out if I had a way to take a class and listen to all methods called on it. Is there a way to do that? I tried redefining Products to nil, so that any method called would throw an error, it didn't seem to work.

dansch
  • 6,059
  • 4
  • 43
  • 59

1 Answers1

0

I could find this out if I had a way to take a class and listen to all methods called on it. Is there a way to do that?

Well, you could replace the class with a mock:

Product = mock

From that point on, any method called on Product should generate a failure, e.g. "Mock received unexpected message :find".

zetetic
  • 47,184
  • 10
  • 111
  • 119