blob: 7fa29503f06d79787ad3a4cff6bcda380308a60e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
require 'integration_test_helper'
class TestAuth < CapybaraTestCase
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
login('unregistered', 'password')
assert_text 'Unrecognized user'
end
def test_login
login_with_correct_credentials
assert_equal 200, page.status_code
assert_text "You're logged in!"
end
def test_logout
login_with_correct_credentials
visit '/logout'
assert_text 'Login'
assert_equal '/', current_path
end
end
|