set current view context in view tests

use before filter in Rspec instead of around
This commit is contained in:
Vasiliy Ermolovich 2012-06-05 18:50:42 +03:00
parent 5756d83ed0
commit ea3aaf6144
1 changed files with 9 additions and 8 deletions

View File

@ -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