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

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.

Re: Trouble with Integration Test

An hour later... I've made some progress, I've got it to accept the params and in the test.log I can see that it is redirecting to the correct second page.  However its still failing at the exact same place -- on the test for a form with action="/account/new_acount_step_two".  I've confirmed that that is the url in the view code for the form.  I've added a puts response.inspect right before the assert select and there it is right in the middle ... <form action="/account/new_account_step_two" ..>

Is there some bug with assert_select caching responses and not updating to the new one?  Something else?

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.