Rails system tests use Capybara. Capybara uses rack_test
driver by default, while System tests uses selenium
by default.
Capybara Drivers:
- rack_test is a small ruby api which works with Rack (a web stack underlying nearly all Ruby web frameworks) - it is unaware of javascript
- selenium a driver to manage libraries enabling web browser automation - it is aware of Javascript as it actually automating a physical web-browser.
I want to know why these were chosen and what are sensible choices for a Rails programmer writing System tests.
System tests run using Capybara. Capybara use drivers to complete the testing. Capybara drivers can be defined as:
Capybara uses by default a rack_test driver, a faster but JavaScript unaware version. while Rails system tests uses by default, a slower but Javascript aware version, selenium - think this code sets the Rails default.
I wanted to know the reasons for the default and if I could still be using
rack_test
. I found a quote from the original PR:So there's no technical reason to choose Selenium vs Rack. Selenium was chosen as it was a fuller functioned low configuration default.
Rack test is limited it was described as:
If your system test isn't using Javascript you may consider using
rack_test
instead. However, it's a trade off - rack will be faster because it doesn't know about Javascript but it can't replace the complexity of a physical browser.