Sometimes when we place expectations on class methods, the class
methods seem to be not available in their previous form for other,
later specs. Calling the class methods in other specs result in a no
method error. We commonly find this happening when model specs run
after controller specs - the Model.find expectations in controller
specs make Model.find actual calls in model specs result in errors.
Running them in reverse removes the errors.
I’m wondering if I’m using RSpec wrong, or if it’s a bug. My
assumption is that after the example group in which the expectation
has been placed, the original functionality of the class is restored.
That’s supposed to be the function of of Proxy#reset_proxied_methods,
if I’m understanding the RSpec source correctly.
Here’s a link to a minimal, standalone, example of what I’m talking
about, although it deals with define_method instead of find. The
output we get when running the specs is in the pastie at the bottom,
It’s extracted from a Rails app but has been modified to be run on
it’s own, with no external dependencies or configuration. The error
happens under 1.1.11 and also edge RSpec from github. We are seeing it
on Mac 10.5 and also Ubuntu 8.04.
jlindley@Hypatia:~/sites/cpi2/spec/models(master)$ spec -v
jlindley@Hypatia:~/sites/cpi2/spec/models(master)$ ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]