Add tests for main controller

This commit is contained in:
Erik Michaels-Ober 2011-05-15 15:07:53 -07:00
parent 9807f33add
commit 7128651e17
2 changed files with 27 additions and 1 deletions

View File

@ -4,7 +4,7 @@
%p#tagline %p#tagline
Claim responsibility for shoveling out a fire hydrant after it snows. Claim responsibility for shoveling out a fire hydrant after it snows.
= form_for :address, :html => {:id => "address_form"} do |f| = form_for :address, :html => {:id => "address_form"} do |f|
= label_tag "city_state", "City", :id => "city_label" = label_tag "city_state", "City", :id => "city_state_label"
= select_tag "city_state", '<option value="Boston, MA" selected="selected">Boston, MA</option>'.html_safe, :tabindex => 10 = select_tag "city_state", '<option value="Boston, MA" selected="selected">Boston, MA</option>'.html_safe, :tabindex => 10
= label_tag "address", "Address", :id => "address_label" = label_tag "address", "Address", :id => "address_label"
= text_field_tag "address", params[:address], :tabindex => 11 = text_field_tag "address", params[:address], :tabindex => 11

View File

@ -0,0 +1,26 @@
require 'test_helper'
class MainControllerTest < ActionController::TestCase
test 'should return the home page' do
get :index
assert_response :success
assert_select 'title', 'Adopt a Hydrant'
assert_select 'h1', 'Adopt a Hydrant'
assert_select 'p#tagline', 'Claim responsibility for shoveling out a fire hydrant after it snows.'
assert_select 'form' do
assert_select '[action=?]', '/'
assert_select '[method=?]', 'post'
end
assert_select 'label#city_state_label', 'City'
assert_select 'select#city_state' do
assert_select 'option', 'Boston, MA'
end
assert_select 'label#address_label', 'Address'
assert_select 'input#address', true
assert_select 'input[name="commit"]' do
assert_select '[type=?]', 'submit'
assert_select '[value=?]', 'Find fire hydrants'
end
assert_select 'div#map_canvas', true
end
end