-
Notifications
You must be signed in to change notification settings - Fork 234
/
main_controller_test.rb
38 lines (34 loc) · 1.1 KB
/
main_controller_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
require 'test_helper'
class MainControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
request.env['devise.mapping'] = Devise.mappings[:user]
@user = users(:erik)
end
test 'should return the home page' do
get :index
assert_response :success
assert_select 'title', 'Adopt-a-Hydrant'
assert_select 'p#tagline', 'Claim responsibility for shoveling out a fire hydrant after it snows.'
end
test 'should show search form when signed in' do
sign_in @user
get :index
assert_response :success
assert_select 'form' do
assert_select '[action=?]', '/address'
assert_select '[method=?]', 'get'
end
assert_select 'label#city_state_label', 'City'
assert_select 'select#city_state' do
assert_select 'option', 'Boston, Massachusetts'
end
assert_select 'label#address_label', 'Address, Neighborhood'
assert_select 'input#address', true
assert_select 'input[name="commit"]' do
assert_select '[type=?]', 'submit'
assert_select '[value=?]', 'Find hydrants'
end
assert_select 'div#map', true
end
end