On Mon, Dec 14, 2009 at 3:26 AM, Andrei Erdoss <erd...@gmail.com> wrote: > On Mon, Dec 14, 2009 at 9:05 AM, Amit Kulkarni <li...@ruby-forum.com> wrote: >> >> Thanks David, >> Now in spec when i write login_as :admin then there must be some method >> written for login_as? >> Now if there are before filters in controller then do we need to write >> each and every method or it is indeed taken care of but the developer >> and we need to just have to pass the value for that particular before >> filters. >> For e.g. >> If i have a before filter in controller as >> before_filter :admin_access_required, :except=>[ :view, >> :update_presentation] >> Now in my spec do i need to pass only the value like >> admin_access_required :admin >> or i need to write some method for the same > > You can write a stub method that would return a value such that your object > meets the admin_required_access requirement. > > controller.stub(:admin_access_required).and_return(true)
That _could_ work, but methods like admin_access_required are often implemented such that they modify the internal state of the controller, setting the user on its internal session or request object. If the behaviour subsequently invoked by the example needs to access that state, this wouldn't work. Cheers, David > > -- > Andrei Erdoss _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users