Here’s a test case that I’m working on:
it "should allow you to login" do
visit "/"
fill_in 'Email', :with => 'user@example.org'
fill_in 'Pass', :with => 'password'
click_button 'Login'
current_url.should =~ /dashboard/
end
This particular test is failing. What I’d like to know is if it’s failing because it’s not able to log in, but failing because I’m checking the current_url too fast. What’s the proper way of ‘waiting’ until the click_button task executes and rails redirects the user?
Have you tried manually going to your home page, logging in with those credentials, and then seeing what happens? If you’re able to do it, then you’re able to rule out the idea of it not working.
I would suggest using the built in assertions instead of matching on the name of the URL. Like so:
You won’t have to wait for your button to click, in either case.