rspec/rspec-mocks — Issue #92: stub method not found in before(:all) block
Author: wjdix
Created: 2011-12-16 14:49:28+00:00
State: open

Migrating from Rais 2.3 to Rails 3 and Rspec 1 to Rspec 2. Previously passing test with stub in before(:all) block no fails. I added the scenario below to the rspec-mock feature suite and it fails.

``` cucumber
Scenario: stub in a before(:all) block
Given a file named "example_spec.rb" with:
"""
class Foo ; end
describe "a stub in a before(:all) block" do
before(:all) do
Foo.stub(:find)
end
it "return nil" do
Foo.find.should be(nil)
end
end
"""
When I run `rspec example_spec.rb`
Then the examples should all pass
```

```
(::) failed steps (::)

expected "F\n\nFailures:\n\n 1) a stub in a before(:all) block return nil\n Failure/Error: Foo.stub(:find)\n NoMethodError:\n undefined method `stub' for Foo:Class\n # ./example_spec.rb:4\n\nFinished in 0.00029 seconds\n1 example, 1 failure\n\nFailed examples:\n\nrspec ./example_spec.rb:6 # a stub in a before(:all) block return nil\n" to include "0 failures" (RSpec::Expectations::ExpectationNotMetError)
features/method_stubs/simple_return_value.feature:96:in `Then the examples should all pass'
```