[rspec-users] how do I test for a status code in a :js => true test?

Patrick J. Collins patrick at collinatorstudios.com
Thu May 10 04:14:38 UTC 2012

I have a view with some javascript that does page redirection, and I
wanted to confirm that under certain circumstances the user will get a
500 error from CanCan::AccessDenied.

It seems that when I am not using :js => true, I can do:

page.status_code.shoud be 500

but.. when I try that in a :js => true example group, I get:
Capybara::NotSupportedByDriverError: Capybara::NotSupportedByDriverError

also the request and response objects are nil in the context of this
test...  My dirty workaround has just been to do:

page.has_content "CanCan::AccessDenied"

Which serves my purposes, but I was hoping for a better way...  Any

Thank you.

Patrick J. Collins

More information about the rspec-users mailing list