rspec/rspec-core — Issue #473: use object.stub in before(:all)
Author: senny
Created: 2011-10-12 14:38:49+00:00
State: open

I am facing the problem, that I need to stub out a method in a `before(:all)` block. When calling `stub` the following exception is raised:

Failure/Error: ExampleModel.stub(:cachers => [])
NoMethodError:
undefined method `stub' for #

I tried to debug the problem and i noticed, that it happens because the Mocks are setup in the `RSpec::Core::Example#run_before_each` method. The bad part is, that everything works perfectly, when I got an `it "..." do; end` block above the `before(:all)` block. This will trigger the mock setup and will make the example pass.

Is there a way to make the mocking already available when the `before(:all)` block is the first element in the spec file?