On Aug 3, 2006, at 8:16 PM, Jeremy Friesen wrote:
> I have a test method (below).
>
> def test_save_failed
> post( :edit, :record => StatusChanger.invalid_data_hash)
> assert_response :success
> assert_template ''edit''
> assert assigns(:record)
> assert_equal false, assigns(:record).valid?
> end
>
> This particular method is part of a larger set of functional
> tests. If
> I run,
>
> $ ruby controller_test.rb -n ''test_save_failed''
>
> it validates fine. If I run,
>
> $ ruby controller_test.rb
>
> I receive the following:
>
> "Expected response to be a <:success>, but was <302>"
>
> I''m utterly confused. Any ideas?
Just a wild guess...
Oftentimes when a test works as expected when run individually but
fails as part of a larger sequence, it is due to there being some
artifact left behind in the environment. Take a look at your session
to see if it is the culprit. Also, if you are using MySQL, make sure
you are using InnoDB tables so that transactions are properly rolled
back between tests.