diff options
| author | Teddy Wing | 2015-12-08 01:17:26 -0500 |
|---|---|---|
| committer | Teddy Wing | 2015-12-08 01:17:26 -0500 |
| commit | 6eef2d15e7935dc21580dd7c9e4042d3b8564b4d (patch) | |
| tree | 831fe36fad5549d6cb2bf99ed1d94cc7b2737270 /test/integration/auth_test.rb | |
| parent | 57b6cac65f2979f948dcfc77e027d8aa54a000ca (diff) | |
| download | Ruby-Web-Sessions-Exercise-6eef2d15e7935dc21580dd7c9e4042d3b8564b4d.tar.bz2 | |
auth_test.rb: Create login helpers
Create a couple new methods to extract login functionality and remove
duplicate test code.
Diffstat (limited to 'test/integration/auth_test.rb')
| -rw-r--r-- | test/integration/auth_test.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/test/integration/auth_test.rb b/test/integration/auth_test.rb index 87d1fb5..3e98788 100644 --- a/test/integration/auth_test.rb +++ b/test/integration/auth_test.rb @@ -2,27 +2,32 @@ require 'integration_test_helper' class TestAuth < CapybaraTestCase - def setup + def login(username, password) visit '/' + fill_in 'username', :with => username + fill_in 'password', :with => password + click_button 'Login' + end + + def login_with_correct_credentials + login('hubertfarnsworth', 'secret') end + def test_index_has_login_form + visit '/' assert_text 'Login' assert has_selector?('//form') end def test_unrecognised_user_login - fill_in 'username', :with => 'unregistered' - fill_in 'password', :with => 'password' - click_button 'Login' + login('unregistered', 'password') assert_text 'Unrecognized user' end def test_login - fill_in 'username', :with => 'hubertfarnsworth' - fill_in 'password', :with => 'secret' - click_button 'Login' + login_with_correct_credentials assert_equal 200, page.status_code end |
