Skip to content

aranetic/barista_test

Repository files navigation

THIS IS A REVIEW COPY. The APIs provided by this gem are still unstable, and may change without warning.

Are you using CoffeeScript with Rails 3 and Barista? This gem will allow you to run unit tests from the command line. To install, add the following line to your Gemfile:

gem 'barista_test', :git => 'git://github.com/aranetic/barista_test.git'

Ultimately, I would like this gem to support multiple testing libraries (such as Expresso and Vows.js) and various popular supporting libraries (such as sinon and jsdom). For now, only vows is actually supported.

You will need to install from the following repository for now, until some fixes get merged back upstream:

git clone git://github.com/emk/vows.git
cd vows
npm install .

Place your test files in spec/coffeescripts. These files should contain ordinary Vows.js suites (though vows and assert are already loaded for you). For example, if you have the following in app/coffeescripts/example.coffee:

# Figure out where to attach our exported functions.  'exports' works in a
# CommonJS package, and 'this' works in the browser.
root = exports ? this

# The function we want to test.
root.add = (x, y) -> x + y

…you can put the following in test/coffeescripts/example_test.coffee:

example = require 'example'

exports.example_spec = vows.describe("example").addBatch
  'adding 2 and 3':
    topic: 2+3,
    'returns 5': (sum) ->
      strictEqual 5, sum

To run the unit tests, type:

rake barista:test

Declaring the Rake tasks manually

If you’re not using Rails, you will need to add the following task to your Rakefile manually:

require 'barista_test/rake_task'

BaristaTest::RakeTask.new do |spec|
end

About

(Work in progress) Run CoffeeScript unit tests from Rake

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published