From 7128651e17bf96d003cfe86b869bdcedde296870 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sun, 15 May 2011 15:07:53 -0700 Subject: [PATCH] Add tests for main controller --- app/views/main/index.html.haml | 2 +- test/functional/main_controller_test.rb | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/functional/main_controller_test.rb diff --git a/app/views/main/index.html.haml b/app/views/main/index.html.haml index 29c1ed0..3d74b27 100644 --- a/app/views/main/index.html.haml +++ b/app/views/main/index.html.haml @@ -4,7 +4,7 @@ %p#tagline Claim responsibility for shoveling out a fire hydrant after it snows. = 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", ''.html_safe, :tabindex => 10 = label_tag "address", "Address", :id => "address_label" = text_field_tag "address", params[:address], :tabindex => 11 diff --git a/test/functional/main_controller_test.rb b/test/functional/main_controller_test.rb new file mode 100644 index 0000000..adc7ede --- /dev/null +++ b/test/functional/main_controller_test.rb @@ -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