Test Redirection with RSpec and Capybara (Rails)
Try current_path.should == "/projects/show"
Capybara also implements a current_url
method for the fully qualified URL.
More info in the docs.
EDIT
Capybara now has a RSpec matcher called have_current_path, which you can use like: expect(page).to have_current_path(some_other_page_path)
(thanks @bjliu)
Im not sure that this can be what you need, but in my tests I prefer such approach:
...
subject { page }
...
before do
visit some_path_path
# do anything else you need to be redirected
end
it "should redirect to some other page" do
expect(page.current_path).to eq some_other_page_path
end