I have some questions about testing RJS. First of all, just
generally, how important is testing RJS? It seems, that for effects
at least, if I can see that the effect is working, then that is good
enough for me?
In View testing in general, there are some overlapping rules of thumb:
- do test what you don’t want to break
- don’t test glitz (colors, shiny things, animated GIFs, etc.)
- do test that your business-side variables got embedded correctly
- do test navigation (such as links and redirect_to)
The goal is if you add new features and make a mistake the code will
early as possible. But if you break glitz, you can easily see it’s
you can easily fix it without affecting your new features.
I would like to test certain RJS redirect_to’s
however. I came across the ARTS plugin. Has anyone had any
experience using this with rails 2.2 or 2.3?
Yes; just install the plugin.
After you start using assert_rjs, look up my assert_rjs_. It’s nearly a
replacement for the most common RJS situations, but it’s much more
It does not test redirect_to, but if it did then it would not be much
powerful than assert_rjs Classic, so use that for now.
I saw somewhere that it
was included in 2.2, but when I try:
assert_rjs :redirect_to, :action => ‘show’
I get an unknown method error.
The documentation for the ARTS will tell you how to install a plugin.
to do with script/plugin install…
assert_rjs_ is a gem, not a plugin, because test-side things don’t need
deploy to your server. Use assert_rjs_ when you start working with