Today I learned that when using a binding.pry
like this inside a Capybara feature test
require "test_helper"
feature "User::CanResetPassword" do
before do
visit reset_password_path
end
scenario "valid email" do
binding.pry
within("form[action='/password_resets']") do
fill_in "Email", with: "admin@example.com"
end
click_button "Submit"
current_path.must_equal sent_password_path
end
you can use the following method
pry(#<User::CanResetPassword Feature Test>)> save_and_open_page
This opens the page content in a browser. Which makes it easier to debug if the selector you think should match something doesn't match anything.
Source: http://www.stefanwille.com/2010/12/printing-the-page-content-in-capybara/