Patrick J. Collins
2012-May-10 04:14 UTC
[rspec-users] how do I test for a status code in a :js => true test?
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? Thank you. Patrick J. Collins http://collinatorstudios.com
David Chelimsky
2012-May-10 11:45 UTC
[rspec-users] how do I test for a status code in a :js => true test?
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.