Forum: Ruby on Rails Issues with Functional Tests

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (Guest)
on 2007-04-21 23:08
(Received via mailing list)
I'm running rails-1.2.3 under Ubuntu 6.06, and I've come across a few
I'd like to raise.

(1) If a controller sets[:notice] = "message", then in a
functional test I don't seem to be able to match it.

flash.inspect shows "{}" and shows
"#<ActionController::Flash::FlashNow:0xb63c4ecc @flash={}>"

However it's fine for a normal flash message with a redirect. Is there a
to test directly that a controller has put something into ?

I can workaround by using

   assert_select "div#notice", /whatever/

although that hard-codes knowledge of what the layout is using to
the flash.

(2) One of the things I'd most like to test is simply whether the
page is well-formed XHTML, to check if I've missed out any balancing
tags in
my RHTML templates. Ideally I'd like "assert_result :success" to check
well-formedness, or to have a separate assert_well_formed.

What would be the best way to achieve this? Does
   assert_select "html"
by itself enforce that the entire document is well-formed?

(3) When using submit_tag, there doesn't seem to be a simple way to do
:confirm => "Are you sure?" like you can with link_to and button_to.

I can workaround by writing something like this:

<%= submit_tag "Copy", :onclick => "return
#{confirm_javascript_function("Are you sure?")};" %>

Is there an easier way to achieve this?


This topic is locked and can not be replied to.