Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Run QUnit JavaScript unit tests, integrate them into Ruby applications.

branch: master
README.rdoc

Everqueen

“Because QUnit is just really simple.”

Everqueen is a tool to run javascript unit tests for client side JavaScript. It combines a server which allows you to serve up and run your tests in a browser, as well as a runner which uses Capybara and any of its drivers to run your tests. Everqueen uses the QUnit unit testing framework for JavaScript.

github.com/hornairs/everqueen

Fork Note

Everqueen is a serious fork of Evergreen by Jonas Nicklas. Evergreen rocks, but we wanted to use QUnit instead of Jasmine, and use Sprockets for serving up test files instead of the homebrew require system in Evergreen. Thank Jonas for his awesome OSS work on Evergreen, because he took us 99% of the way there.

Philosophy

Everqueen is a unit testing tool. Its purpose is to test JavaScript in isolation from your application. If you need a tool that tests how your JavaScript integrates with your application you should use an integration testing framework, such as Capybara.

Installation

Install as a Ruby gem:

gem install everqueen

Usage

Everqueen assumes a file and directory structure, place all your javascript code inside ./public and all test files inside ./test/javascripts. All test files should end in _test.js. For example:

public/javascripts/widget.js
test/javascripts/widget_test.js

You can require files from the public directory inside your test file:

require('/javascripts/widget.js')

test('a widget', function() {
  ...
});

You can now look at your test files inside a browser by starting up the Everqueen server:

everqueen serve

Alternatively you can run the tests headlessly by running:

everqueen run

Integrating with Rails 3

Add Everqueen to your Gemfile:

gem 'everqueen', :require => 'everqueen/rails'

Start your rails application and navigate to /everqueen. You should now see a list of all test files, click on one to run it.

There's a rake task provided for you that you can use to run your tests:

rake test:javascripts

Integrating with Rails 2

Add the following line to your Rakefile:

require 'everqueen/tasks'

This will give you the `test:javascripts` rake task. Note that mounting is not possible under Rails 2 and that `require 'everqueen/rails'` will fail.

Configuration

By default, Everqueen uses Selenium to run your tests and assumes a certain directory structure. If this standard is fine for you, then you don't need to do anything else. If you need to configure Everqueen to suit your needs, Everqueen will automatically look for and load the following files:

config/everqueen.rb
.everqueen
~/.everqueen

The content of these files could look like this:

require 'capybara-webkit'

Everqueen.configure do |config|
  config.driver = :webkit
  config.public_dir = 'public_html'
  config.test_dir = 'test'
end

Test Helper

If you add a test_helper file like so:

test/javascripts/test_helper.js

It will automatically be loaded. This is a great place for adding custom matchers and the like.

CoffeeScript

Everqueen supports tests written in CoffeeScript via Sprockets. Just name your test file _test.coffee and it will automatically be translated for you.

You can also add a CoffeeScript test helper, but remember that CoffeeScript encloses individual files in a closure, if you need something you define in the test helper to be available in your test files, attach it to the window object:

# test/javascripts/test_helper.coffee

MyThing: "foo"          # local to test helper
window.MyThing: "foo"   # global

Development

If you plan to work on Everqueen, you need to checkout the QUnit library, which is added as a git submodule. Run the following command:

git submodule update --init

If you're using a version of Everqueen from git with bundler, you need to tell bundler to use submodules, this can be achieved with the following command:

gem 'everqueen', :submodules => true, :git => 'git://github.com/jnicklas/everqueen.git'

License:

(The MIT License)

Copyright © 2009 Jonas Nicklas

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.