Browse files

Reuse the view_context from the controller, this make the test enviro…

…nment more similar to the code applications uses
  • Loading branch information...
1 parent 6ddabaa commit daada51d1051948c3e6de963a90c4b5bb5bf142b @spastorino spastorino committed Jan 12, 2011
Showing with 1 addition and 4 deletions.
  1. +1 −4 actionpack/lib/action_view/test_case.rb
View
5 actionpack/lib/action_view/test_case.rb
@@ -156,11 +156,8 @@ def _render_partial(options)
# The instance of ActionView::Base that is used by +render+.
def view
@view ||= begin
- view = ActionView::Base.new(ActionController::Base.view_paths, {}, @controller)
- view.singleton_class.send :include, @controller._helpers
+ view = @controller.view_context
view.singleton_class.send :include, _helpers
- view.singleton_class.send :include, @controller._routes.url_helpers
- view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
view.extend(Locals)
view.locals = self.locals
view.output_buffer = self.output_buffer

1 comment on commit daada51

@dnagir

Pretty sure that this commit breaks tests.

Especially the RSpec ones.
This is happening because of @controller is nil before running the view specs.

See more at rspec/rspec-rails#833 (comment)

Would that be rails' problem or RSpec's and what would be the best way to workaround it?

Please sign in to comment.