Topic: Trouble with Integration Test
I'm doing my first set of integration tests and I'm not sure what I'm doing wrong.
The code fails on the second "click_button" call on the first assert inside the call. Debugging has shown that the controller handling the first click_button isn't using the passed params so the initial validation fails and its not redirecting to the second step. The controller test for the individual actions work and are using identical params.
Here's my test case:
require "#{File.dirname(__FILE__)}/../test_helper"class AccountCreationTest < ActionController::IntegrationTest
def test_personal_account_creation
goto_home_page
click_link "Create Account", "/account/new_account_step_one"
click_button "Next Step", "/account/new_account_step_one", {:user=>{:username=>"TestUser",
:password=>'T3st!ng', :password_confirmation=>'T3st!ng', :account_type=>'Personal'}}
click_button "Create Account", "/account/new_account_step_two", {:first_name=>'Test', :last_name=>'User'}
end
private
def goto_home_page
get "/"
assert_response :success
assert_template "register/list"
end
def click_link(link_text, destination)
assert_select "a[href*=#{destination}]", link_text
get destination
assert_response :success
end
def click_button(button_text, destination, params={})
assert_select "form[action=#{destination}]" do
assert_select "input[type=submit][value=#{button_text}]"
end
post_via_redirect destination, params
end
end