Skip to content

Instantly share code, notes, and snippets.

@delba
Created June 21, 2013 23:33
Show Gist options
  • Select an option

  • Save delba/5835109 to your computer and use it in GitHub Desktop.

Select an option

Save delba/5835109 to your computer and use it in GitHub Desktop.
Use helpers in Capybara tests
module FormHelper
def login_form
find('#new_session')
end
end
class SignInTest < ActionDispatch::IntegrationTest
include FormHelper
setup do
@sophie = users(:sophie)
end
test "sign in with valid credentials" do
visit sign_in_url
within login_form do
fill_in "Email", with: @sophie.email
fill_in "Password", with: 'secret'
click_button "Sign In"
end
assert page.has_content?("Signed in as #{@sophie.email}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment