a work on process

Rails flash tests deprecated?

You are reading a post by James Stewart entitled Rails flash tests deprecated?. It was posted on 5 September 2006 at 6:39 am.

You can find more posts by returning to the index.

Filed under: Notes
Tagged: , , , ,

After returning from a weekend away, updating my apps to the latest Edge Rails, and running my test suite I started spotting new deprecation warnings:

DEPRECATION WARNING: assert_flash_exists is deprecated and will be removed from Rails 2.0
DEPRECATION WARNING: assert_flash_has is deprecated and will be removed from Rails 2.0

Kevin Clark has posted on the deprecation of assert_tag in favour of assert_select, but I’ve yet to see any notes on this one. Looking in the actionpack CHANGELOG there’s no reference to the change, and there’s no documentation in the new home of those methods (actionpack/lib/actioncontroller/assertions/deprecated_assertions.rb) to suggest what we should use instead other perhaps than making use of the code used in those methods. eg:

assert_flash_has :notice
assert_flash_equals :notice, 'This is a notice'

becomes

assert @response.has_flash_object?(:notice)
assert_equal 'This is a notice', @response.flash[:notice]

Obviously testing the flash contents is not a way to test the key behaviours of an application, but I often use these tests to make sure I’ve remembered to set notices in the right places. Does anyone know why they’ve been deprecated?

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Posts

 

2 Comments »

  • Hi there. assert_flash_equals and friends were deprecated around 0.11 if I recall. The core decided that there were too many specific assertions in Rails itself. If you still want these things feel free to pull your own versions into test/test_helper.rb

    Comment by Kevin Clark — 6 September 2006 @ 3:29 pm

  • Ah. I guess I must have been thrown by the newly added deprecation warnings? Thanks for clarifying.

    Comment by James Stewart — 6 September 2006 @ 3:59 pm

TrackBack URI

Leave a comment

Login Method

OpenID

Anonymous