Testing RJS with ARTS

Posted by marcel May 31, 2006 @ 02:51 PM

An Achilles’ heal of Rails is no good way to test your RJS. As the presentation behavior gets more and more sophisticated, the inability to test it becomes a real problem. Not anymore.

Kevin Clark has released ARTS, a mechanism to test RJS. His API is simple yet flexible. A single point of entry let’s you test a considerable amount of the RJS you can generate. Here’s an idea of what you can do:

  assert_rjs :alert, 'Hi!'                                                     
  assert_rjs :assign, 'a', '2'                                                 
  assert_rjs :call, 'foo', 'bar', 'baz'                                        
  assert_rjs :draggable, 'draggable_item'                                      
  assert_rjs :drop_receiving, 'receiving_item'                                 
  assert_rjs :hide, "post_1", "post_2", "post_3"                               
  assert_rjs :insert_html, :bottom, 'posts'                                    
  assert_rjs :redirect_to, :action => 'list'                                   
  assert_rjs :remove, "post_1", "post_2", "post_3"                             
  assert_rjs :replace, 'completely_replaced_div', '<p>This replaced the        
div</p>'                                                                       
  assert_rjs :replace_html, 'replaceable_div', "This goes inside the           
div"                                                                           
  assert_rjs :show, "post_1", "post_2", "post_3"                               
  assert_rjs :sortable, 'sortable_item'                                        
  assert_rjs :toggle, "post_1", "post_2", "post_3"                             
  assert_rjs :visual_effect, :highlight, "posts", :duration => '1.0'           

He’s written up an extensive tutorial to get you up and running.

Posted in Documentation, Sightings | 10 comments

Comments

  1. Dave on 31 May 16:19:

    Now i’ll make an audio layer and call it Rails… come on..

  2. Sam Leibowitz on 31 May 17:53:

    Minor typo alert: that should be “Achilles’ heel,” not “Achilles heal.”

    But thanks for the very informative link!

  3. Kevin Clark on 31 May 18:56:

    Dave: rjs_assertions was taken ;) It’s Another RJS Testing System.

  4. null on 31 May 19:51:

    why does thos blog look like sh*t on IE on windoze XP? I use firefox on my mac from home, but this is ridiculous.

  5. dizave on 01 Jun 00:25:

    For me the achilles’ heel is postgres testing support :D

  6. Wasted Duplication on 01 Jun 10:47:

    Nice work!

    But, it would have been better to just fix the existing rjs asertion plugin instead of making another one.

  7. Null by Null on 01 Jun 14:47:

    Wasted, that won’t be very DRY, that is why its always better to create a new plugin. Fixing the old code is sooo yesterday and NON_DRY! HELLLOOOOO! Pluse if we leverage the broadband with the web 2.0 and whip the eyeballs with the long tail, we should be able to do a startup with more joy and less pain.

    P.S. Please fix the firkin flagship site, its horrible on IE.

  8. CS on 01 Jun 15:05:

    Another voice crying out in pain on the IE issue.

    Wish I could use Firefox at work but my IT department has locked down my machine

  9. averyv on 02 Jun 01:58:

    bust on ie. kill it now.

  10. MichaelW on 02 Jun 11:08:

    See my original post on the IE issue and some responses here (http://www.ruby-forum.com/topic/67202#83341). A couple of people suggested fixes. Not sure who needs to implement one or the other of them.