The following blog post contains material either currently found or soon to be incorporated into my new book, "Easy Active Record for Rails Developers". Among many other topics, you'll learn about model generation, migrations, validations, associations, scopes, joins, includes, forms integration, nested forms, and model testing with RSpec and FactoryGirl. The book is now available, head over to this website's home page to learn more.
Occasionally you’ll write a Capybara test which produces an unintended outcome. You’ll run and tweak the test a few times, but it continues to inexplicably fail. One easy way to debug the problem involves viewing the page as the test sees it. To do so just output the
page.body, as demonstrated below:
scenario 'Clients should not see the subscribe button', js: true do visit company_path(trial_owner.company) puts page.body expect(page).not_to have_css '.stripe-button-el' end