On the rspec-users mailing list, Zach Dennis had a great response to
my question:
------------------------------
On Sun, Sep 28, 2008 at 11:59 PM, Nick Hoffman
<nick-qGbiljoI0DQkmLvzuZlaBw@public.gmane.org>
wrote:
I just discovered that I need to pass :chained_replace_html to
#have_rjs ,
like so:
response.should have_rjs(:chained_replace_html, :hide, ''map-filter-
errors'')
However, after googling around and looking through the source for
#assert_select_rjs , I have no idea what :chained_replace_html does,
nor why
:hide is insufficient. Would someone mind enlightening me?
------------------------------
On 2008-09-29, at 19:33, Zach Dennis wrote:
The problem has to do with the javascript that is produced by Rails.
You can do things in RJS in one of two ways.
Way #1:
page[:some_id].hide
Way #2
page.hide :some_id
Based on which way you go Rails will generate
Element.hide(''some_id'')
or $(''some_id'').hide() IIRC. assert_rjs uses regular
expressions to
match against the generated javascript. The fugliness that are these
regular expressions require that two different patterns exist to match
against the generated javascript correctly.
Having chained_replace_html is a hack to separate the regular
expressions based on if you used Way #1 or Way #2.
I have stopped relying on using RJS selectors to test against
generated JavaScript. I have also stopped relying on RJS for the most
part, and instead am doing a lot of UJS and JSON (thx Mark VanHolstyn
for enlightening me on this). I''m not saying that you
shouldn''t do
this, but that I''ve hit the problem you''re facing, and I
don''t think
using regular expressions from the bowels of Rails for asserting
against generated javascript is the way to go,
--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---