alphagov/whitehall — pull request #1925 by tekin (2014-12-22 14:12:10+00:00)
Title: Speed up features

Capybara's "presence" finders (e.g. `has_css?`) are designed to work with pages that may be loading in content via remote AJAX calls, and therefor will wait for a default amount of time if something cannot immediately be found on the page (in our case, this `Capybara.default_wait_time` is set to 5 seconds). The upshot of this is that if a "presence" finder is used to verify that something is **not** on the page, there will be a delay until this default wait time has passed. Instead, we can use the corresponding "absense" finder (e.g. `has_no_css?`) to avoid this delay.

A related issue is using these finders in conditionals to perform different actions depending on the state of the page (see `fill_in_change_note_if_required` below). If the condition is met, there is no delay, but if it isn't, we get a delay. In these cases, we can avoid the delay by explicitly telling capybara not to wait.

In reality, the speed gains from these changes are modest, but they should help reduce the chance of intermittent failures on CI.

See http://blog.codeship.com/faster-rails-tests/ for more background.