From ea3aaf61441d3b015061c2f94ebe6af8ba73c72c Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Tue, 5 Jun 2012 18:50:42 +0300 Subject: [PATCH] set current view context in view tests use before filter in Rspec instead of around --- lib/draper/rspec_integration.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/draper/rspec_integration.rb b/lib/draper/rspec_integration.rb index dd944fa..14559a8 100755 --- a/lib/draper/rspec_integration.rb +++ b/lib/draper/rspec_integration.rb @@ -12,14 +12,15 @@ RSpec.configure do |config| } # Specs tagged type: :decorator set the Draper view context - config.around do |example| - if :decorator == example.metadata[:type] - ApplicationController.new.set_current_view_context - Draper::ViewContext.current.controller.request ||= ActionController::TestRequest.new - Draper::ViewContext.current.request ||= Draper::ViewContext.current.controller.request - Draper::ViewContext.current.params ||= {} - end - example.call + config.before :type => :decorator do + ApplicationController.new.set_current_view_context + Draper::ViewContext.current.controller.request ||= ActionController::TestRequest.new + Draper::ViewContext.current.request ||= Draper::ViewContext.current.controller.request + Draper::ViewContext.current.params ||= {} + end + + config.before :type => :view do + controller.set_current_view_context end end