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

David Chelimsky dchelimsky at gmail.com
Thu May 10 11:45:23 UTC 2012

On Wed, May 9, 2012 at 11:14 PM, Patrick J. Collins
<patrick at collinatorstudios.com> wrote:
> 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
> ideas?

Not sure. I'd post this to the Capybara list.

More information about the rspec-users mailing list