I have non-Javascript specs and Javascript feature specs that use capybara/capybara-webkit.
I have some tests that I expected to fail when in non-Javascript mode, but they are passing. I've tried the functionality in my browser with Javascript turned off, and the functionality does indeed not work as expected. But in Capybara, it works.
I've also tried adding js: false
to the individual test, to make sure there wasn't something hidden in my config turning it on. The spec still passes.
The selenium gem is not included in my Gemfile.
I see two possibilities: your tests are correct but there might be some reason why they pass unexpectedly, or your tests are incorrect and are passing for the wrong reason when you run them in Javascript.
A few suggestions for how to debug that apply to both possibilities:
Use a debugger. (If you have, let us know what you learned.)
Look at the Rails log from a single run of a spec to see what controller actions are called and in what order.
Use save_and_open_page
to snapshot your page and see whether your spec should pass on what you're looking at.
Double-check your tests when run with Javascript:
Run them with the poltergeist driver instead of the capybara-webkit driver. It gives better error messages than capybara-webkit and can be configured to report Javascript error messages.
Use save_screenshot
to take an actual screenshot of the page and verify that the spec is not passing for a spurious reason, perhaps because some content is off the screen.
If you want to be sure whether rspec is running Javascript, use ps
to see whether there is a capybara-webkit or phantomjs process running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With