I have a number of view specs that need certain methods to be stubbed. Here's what I thought would work (in spec_helper.rb):
Spec::Runner.configure do |config|
config.before(:each, :type => :views) do
template.stub!(:request_forgery_protection_token)
template.stub!(:form_authenticity_token)
end
end
But when I run any view spec it fails with
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.template
Doing the exact same thing in the before(:each) block of each example works great.