Options for full stack testing in Ruby on Rails

There are many options for testing Full-Stack for Rails applications. Some use real browsers, some headless, some don't run javascript at all.

What tools do you use or recommend and why?

List of powerful browser simulators or automation :

  • Native Rails support for integration and functional tests (no JS)
  • Webrat
  • Webrat :: Selenium
  • Selenium
  • Celerity (via Culerity)
  • Watir
  • ...

List of testing DSL and frameworks :

  • Rails defaults (assertions, ...)
  • Shoulda
  • Cucumbers
  • Capybara (unified DSL for multiple browser simulators)
  • ...
+6
ruby-on-rails unit-testing selenium testing cucumber
source share
4 answers

All rail applications benefit from good coverage of unit and function tests, regardless of whether you use rspec or shoulda, etc., it is mostly a matter of personal preference. I shoulda fan mainly for the contextual blocks that it provides, which simplifies and simplifies the setup of test cases.

I do not think browser simulators / machines are needed if your application is not very javascript. I would recommend using them only for testing javascript, and for this it is definitely better to go with driving a real browser than simulate. The application I'm currently working on is pretty heavy javascript, and we use cucumber along with watir / firewatir to run our cucumber tests in firefox for javascript-driven functions on our site.

+2
source share

I used a bunch of things during my Rails career over the past few years.

He is currently working on a rather large Rails application on JRuby with very reliable test coverage, and our stack looks like this.

Device Testing:

  • RSpec coverage for models, helpers, libraries, and controllers. Controller coverage is very high.
  • JSpec coverage for a project using some pretty sophisticated JS and HTML 5 wizardry

Functional Testing:

  • Cucumber using Capybara and Culerity (we just switched from WebRat to get Cucumber's JS-heavy fronts)
  • Selenium, which is now a "legacy" and slowly migrates to cucumber / capybara.
+1
source share

In the project I'm currently working on, to test the full stack, we use Cucumber with capybara as the driver.

The front end is very heavy javascript, I tried a couple of mute browser drivers (capybara-envjs and akephalos), but both of them incorrectly performed tests that were passed in a real browser.

+1
source share

I am using Cucumber + Capybara with a combination of selenium-webdriver and a rack driver. Capybara does a good job of abstracting the differences between browser tests that are run by selenium-webdriver for testing, which can actually verify that JavaScript works in the browser, but take some time to run and test, which simply run against the HTML created by the / controller actions that work much faster but do not validate JavaScript. This means that the same set of scripts and step definitions can be run in the browser or not, without the need to maintain duplicate sets of step definitions.

+1
source share

All Articles