hmm... works, but obviously not a good looking one... thanks a lot
anyway. I would see if I could come up with something.
Phlip wrote:
> goodwill wrote:
>
> > As title, I want to have my functional test check results from a json
> > render result, how can I achieve this?
>
> gem install assert_xpath
>
> then in your test:
>
> assert_xml @response.body
> js = assert_xpath('//path-to/your/javascript').text
> assert_javascript js
> json = assert_xpath('//path-to/your/json')
> hash = assert_json(json)
> assert{ hash[:value] == 42 }
>
> That is a long row to hoe just to get down to a 42. (You cannot unit test the
> result of rendering the json into a browser, either way.) So you could stop
> after the second line and just use:
>
> assert{ js =~ /value: 42/ }
>
> --
> Phlip
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---