Debugging Rails System Specs with Pry

In order to pause a spec so that you can debug client/backend, add focus: true, selenium: true to the example’s metadata and binding.pry at the point you want to pause.

Example:

with 'user is logged in', js: true, selenium: true, focus: true do
  login_as @user = FactoryGirl.create(:user)
  visit root_path
  binding.pry # spec will pause here with an open Chrome browser, then you can inspect chrome devtools or use capybara commands in pry console to debug
  expect(current_path).to eq(sites_path)
end

P.S. Selenium or Capybara now overwrite @controller with nil apparently so some other variable name must be used in relevant specs.