Daniel N
2007-Jul-09 13:55 UTC
[rspec-users] Is it bad to use a shared example in rspec_helper.rb?
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? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070709/d74c003f/attachment-0001.html