Guard-Teaspoon: Run Javascript tests with Guard and all the features of Teaspoon.
Ruby JavaScript CoffeeScript
Pull request Compare This branch is 55 commits behind jejacks0n:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Guard Teaspoon

Build Status Code Climate

Guard-Teaspoon allows you to run Teaspoon using Guard.

Teaspoon is a Javascript test runner built on top of Rails. It can run tests in the browser, or headlessly using PhantomJS or with Selenium WebDriver. We recommend you check out the installation steps for Teaspoon, and read about configuration.

With Guard-Teaspoon you can start up Guard, make changes to your tests or implementation files, and the specs will be run automatically using Teaspoon. It behaves very similarly to guard-rspec.

This project is still experimental...

Table of Contents

  1. Installation
  2. Usage
  3. Configuring Guard


Add it to your Gemfile. Like Teaspoon, in most cases you'll want to restrict it to the :asset, or :development, :test groups. You may also want to include one of the filesystem gems that Guard suggests, and in our example we included rb-fsevent.

group :assets do
  gem "teaspoon"
  gem "guard-teaspoon"
  gem "rb-fsevent" # used by guard

Install Teaspoon using the install generator.

rails generate teaspoon:install

Generate the Guardfile that includes the standard Guard-Teaspoon template.

bundle exec guard init teaspoon


Start Guard.

bundle exec guard start

Make changes to your javascript specs or implementation files and the appropriate tests will run.

Configuring Guard

In general this isn't very complicated, but if you have multiple suites setup in Teaspoon this can get a little complicated -- there's an expectation that you understand what you're doing in regards to using Guard.

The default Guardfile will watch for any file changes within your app/assets/javascripts path and will attempt to resolve those file to a spec. If you're using QUnit, you can change this to be _test instead of _spec, or use or coffee for file extensions, and you can use a more advanced regexp for other needs.


guard :teaspoon do
  watch(%r{^app/assets/javascripts/(.+).js}) { |m| "#{m[1]}_spec" }

Specifying Teaspoon Environment

Guard-Teaspoon takes several options, but worth calling out is the environment option. This option allows you to tell Teaspoon where it should look for it's environment file, and is useful if Teaspoon is unable to resolve it's environment.


guard :teaspoon, environment: "spec/dummy/spec/teaspoon_env.rb" do

Available Options

...document when this is better hammered out...


Licensed under the MIT License

Copyright 2012 Mode Set

Make Code Not War