Hi there.
I'm still new to rails and testing with rspec, so hopefully you can help me.
I have a controller which requires login. I use the restful authentication function of rails.
To create things in tests I'm using the factory framework factorygirl.
Ok the problem is the following:
I want to test a controller (authentication required). So I create a new User with
@user = Factory.create(:user)
After this, I login by using:
login_as @user
And the test:
describe "when handling index" do
it "should redirect to root" do
get :index
response.should redirect_to "/"
end
end
Executing this I get the following error:
Net::SMTPAuthenticationError in 'MyCoolController when handling index should redirect to root' 535 5.7.8 Error: authentication failed: authentication failure
The error is raised when creating the user with the factory.
When using fixtures everything seems to work. But I only want to use factories.
Yay that's the problem. Thanks a lot for help :)