Toni Tuominen
2010-Nov-15 05:55 UTC
[rspec-users] debugging calls with message expectations
I''d like to know how to debug callers with message expectations. I have a message expectation that should be called only once but for some reason is called 13 times and I''d like to know where it''s called from. I''ve made the expectation return the value with a block and made it print the call stack but it only prints one stack, not 13 stacks as I would have thought. Why is that? The relevant code is here: https://gist.github.com/026a6c696e2199a46455. I am using rails 3.0.1 and rspec 2.0.1. - Toni
David Chelimsky
2010-Nov-15 14:09 UTC
[rspec-users] debugging calls with message expectations
On Sun, Nov 14, 2010 at 11:55 PM, Toni Tuominen <tjtuom at utu.fi> wrote:> I''d like to know how to debug callers with message expectations. I > have a message expectation that should be called only once but for > some reason is called 13 times and I''d like to know where it''s called > from. I''ve made the expectation return the value with a block and made > it print the call stack but it only prints one stack, not 13 stacks as > I would have thought. Why is that? > > The relevant code is here: https://gist.github.com/026a6c696e2199a46455. > I am using rails 3.0.1 and rspec 2.0.1.For what you''re doing it would be far simpler to say it this way: Course.stub(:find) { puts caller.join("\n"); course } That, or what you have, should expose the caller, so the problem is probably that something else is different in the spec than it is when you run the app. Could be the stuff you''re stubbing like the stub_chain in the before block or the fact that you''re using a mock_model for Signup. HTH, David> > - Toni > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >