I want to extract the method for logging in so that I don't have to include
it in each before call.

Is it bad to use a describe block within the rspec_helper in a rails project
for controller tests?

I have in my spec_helper.rb

describe "an authenticated request", :shared => true do
 before( :each ) do
   @u = mock_model( User )
   mock_login( @u )
 end

 def mock_login( user )
   session[:user] = user
   controller.send( :instance_variable_set, :@current_user, user )
   controller.stub!( :current_user ).and_return( user )
 end

end


which I then share in my relevant controller tests with

 it_should_behave_like "an authenticated request"

Is this bad?
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to