How to test the response code with Capybara + Selenium

deb picture deb · Oct 26, 2011 · Viewed 24k times · Source

I have the following spec:

it "deletes post", :js => true do 
...
...
page.status_code.should = '404'

end 

The page.status_code line is giving me this error:

Capybara::NotSupportedByDriverError

How do I check the page's status code?

Answer

Apie picture Apie · Mar 6, 2013

As an aside. This line

page.status_code.should = '404'

Should be

page.status_code.should == 404

This worked for me with capybara-webkit.