I’m in the process of upgrading an app to Rails 3/Rspec 2. I see that
stubbing a view helper method has changed in Rspec 2. It looks like
instead of doing template.stub!, we’re now supposed to do view.stub!,
but I can’t seem to get this to work on beta 10. I get an “undefined
local variable or method `view’ for
#RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1:0x106785fd0”
error.
I see that in this commit (Changelog for #2685 · rspec/rspec-rails@c76c1e6 · GitHub
0e860f580618045a34c17069b308c093e2e830cb) David removed the view
method, but I can’t figure out what it was replaced with. Something
in ActionView::TestCase::Behavior?
I see that in this commit (Changelog for #2670 · rspec/rspec-rails@a9ae00b · GitHub
0e860f580618045a34c17069b308c093e2e830cb) David removed the view
method, but I can’t figure out what it was replaced with. Something
in ActionView::TestCase::Behavior?
I’m on rails 3.0.0.beta3.
Any idea what I’m missing?
This was an omission from beta.10/11 that I just fixed last night and
will be updated in beta.12.
Short term fix (could be in spec_helper.rb)
module ViewMemoizationFix
def _view @_view ||= view
end
alias_method :view, :_view
end
RSpec.configure do |c|
c.include ViewMemoizationFix, :example_group => { :file_path =>
/\bspec/views// }
end
Let us know if that doesn’t work.
Cheers,
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.