thoughtbot/capybara-webkit — pull request #283 by sdhull (2012-02-28 23:55:17+00:00)
Title: automatic JSON parsing of result from #evaluate_script not always a good thing

I get that it's generally pretty convenient to have that string be JSON parsed, but once in awhile I just want the raw string back (especially when trying to see that js confirmations have the correct text).

Anyway if that call to JSON.parse fails, then you're out of luck. This commit simply rescues with the string that was fed to JSON.parse (the raw result of the evaluate_script call).

Just for some context, this is what I wanted to do in my project:

match = page.evaluate_script(%Q|$('#offer-#{counter_offer.id} input[value="Accept"]').attr('onclick').toString()")|)
match.should include(expected_message)