Created
June 21, 2013 23:33
-
-
Save delba/5835109 to your computer and use it in GitHub Desktop.
Use helpers in Capybara tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module FormHelper | |
| def login_form | |
| find('#new_session') | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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