[rspec-users] Can I construct the controller myself in a controller spec?

Perryn Fowler pezlists at gmail.com
Wed Mar 4 23:38:08 EST 2009


I am experimenting with Constructor based dependency injection for
rails controllers.

So I have something like this

class LoginSessionsController < ApplicationController

  def initialize(authenticator =  TheRealAuthenticator)
    @authenticator = authenticator


The plan was to override the authenticator used when testing with something like

describe LoginSessionsController.new(MyMockAuthenticator) do

but rspec seems to insist on constructing the controller itself

Is there a way to do this I am missing?

More information about the rspec-users mailing list