Terminus is an experimental Capybara driver implemented in client-side JavaScript. It lets you script your application in any browser on any device, without needing browser plugins. This allows several types of testing to be automated:
Terminus is available through Rubygems. For the most part, you will not use it directly: you will use the Capybara API and it will send instructions to Terminus for execution. To set Terminus as your driver:
require 'capybara/dsl' require 'terminus' Capybara.current_driver = :terminus
Terminus does require some extra setup before you can use it to control your app. First up, you need to start the Terminus server on the machine where your application will be running:
$ terminus
This starts the server on port 7004. Now open a browser at 127.0.0.1:7004. (I recommend using the IP address of the Terminus host; Chrome has bugs that can stop WebSockets working if you use the hostname.) This is the ‘holding page’. A browser is said to be ‘docked’ while it is visiting this page, meaning it is ready and waiting to run some tests for you.
Finally, in your tests you need to make sure there's a docked browser and select it. In a before block, run the following:
Terminus.browser = :docked
After each test is finished, you need to return the browser to the holding page to make it ready to accept new work. In an after block:
Terminus.return_to_dock
This returns all currently connected browsers to the holding page.
If you're testing a messaging app, for example, you need several browsers to participate in the test. Terminus has a browser selection API that lets you switch which browser you're controlling as you use the Capybara API.
You can also select based on browser name, version and operating system, for example to select Firefox 3.6 you can call:
Terminus.browser = {:name => /Firefox/, :version => /^3.6/}
The available keys are :name, :version and :os and the values may be strings or regular expressions.