Hi,
in rspec-1 view specs i had the ability to say:
login_as(some_role_or_account)
which made some helper methods like
current_account
that where used in views and controllers return something valuable.
Implementation was based on the fact that the controller in rspec-1
was ApplicationController. My ApplicationController contained a method
for setting the current_account.
In Rspec2 this is broken as the controller in ViewExampleGroup is now
ActionView::TestCase::TestController.
Would anyone know of an elegant way to add functionality, like helper
methods, to this controller instance in all ViewExampleGroups only.
option 1, which i don’t like because it depends on the fact that
ViewExampleGroup uses ActionView::TestCase::TestController:
class ActionView::TestCase::TestController
attr_accessor :current_account
helper_method :current_account
end
module RSpec::Rails::ViewExampleGroup
def login_as account
controller.current_account = account
end
end
I would like to use some hook to add these methods only to the
controller instance used in the view specs, regardless of what class
it is.
There must be an elegant way, is there?
Cheers
Rob