I often find myself wanting to make assertions on what path a user is on after doing some action. Howerver I find that using the
path methods in an integration test is quite clunky.
Now I have a test like this:
scenario "a user signs up" do sign_up_and_log_in_as username: 'david' expect(current_path).to eq user_path User.last expect(page).to have_content 'Welcome david' expect(page).to have_content 'Logout' expect(page).not_to have_content 'Sign up' expect(page).not_to have_content 'Log in' end
There I’m testing that the current path is equal to the last user’s path, but having to call
User.last to get to that user seems not right. It also starts getting complicated when I create more than one user in a single test.
I’m wondering if there is a better way…