-
Notifications
You must be signed in to change notification settings - Fork 5
/
homepage_test.rb
66 lines (53 loc) · 1.44 KB
/
homepage_test.rb
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true
require 'test_helper'
OUTER_APP = Rack::Builder.parse_file('config.ru')
class HomepageTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
OUTER_APP
end
def test_root
get '/'
assert last_response.ok?
end
def test_cave_name_endpoint
get '/cave/Sinatra'
assert last_response.ok?
body = last_response.body
assert body.include?('<h1>The Cave</h1>')
get '/cave/Simon'
assert last_response.ok?
body = last_response.body
refute body.include?('<h1>The Cave</h1>')
end
def test_time_endpoint
get '/time'
assert last_response.ok?
body = last_response.body
assert body.include?('Losing your mind already?')
end
def database_endpoint
get '/database'
assert last_response.ok?
body = last_response.body
assert body.include?('easy peasy database handling')
end
def test_get_user_id_not_logged_in_endpoint
get '/users/1'
refute last_response.ok?
end
def test_new_skeleton_form_endpoint
get '/new_skeleton_form'
assert last_response.redirect?
follow_redirect!
assert last_response.body.include?('You must log in')
end
def test_post_user_signin_endpoint
post '/auth/login', user: { username: 'User', password: 'Secret' }
assert last_response.redirect?
follow_redirect!
assert last_response.ok?
get '/new_skeleton_form'
assert last_response.body.include?('New Skeleton')
end
end