Defining stubs on any instance of an object doesn't work when using the stub! method. This scenario fails:
Scenario: simple any_instance stub with a single return value using the stub! alias
Given a file named "example_spec.rb" with:
describe "any_instance.stub!" do
it "returns the specified value on any instance of the class" do
o = Object.new
When I run `rspec example_spec.rb`
Then the examples should all pass
The stub! method is conceptually (but not formally) deprecated, and is only in place for backward compatibility. I haven't deprecated it with a formal warning yet (mostly to avoid noise - it exists in a lot of places), but this request makes me want to as I'd prefer not to see new code written using it. If I do add it, it would be with a deprecation warning, which seems like a silly thing to do.
I think a warning would be a nice thing. At least when used with any_instance. It was just out of pure luck that I tried it without the bang. It's confusiong because the stub! method still works in any other case...
Raise a helpful message on any_instance.stub! (use stub instead)
- Closes #57.