Project

jaspec

0.0
No commit activity in last 3 years
No release in over 3 years
A stupid simple Jasmine spec-runner for AMD modules
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

 Project Readme

Jaspec Build Status Gem Version

Jaspec is a dirt-simple Jasmine spec runner. It runs off of Jasmine standalone, RequireJS, and PhantomJS. It doesn't care about sprockets; it doesn't start a web server; it does something really really simple:

It runs your specs.

Installation

You can install jaspec via:

$ gem install jaspec

Or, if you're using it with an application that includes a Gemfile, add this line:

gem 'jaspec'

And then execute:

$ bundle

Usage

Running your specs is nice and easy. Just execute:

$ jaspec specs/myCoolSpec.js

Or, if you're using CoffeeScript:

$ jaspec specs/myCoolerSpec.coffee

Finally, if you want to run across an entire directory:

$ jaspec specs/

This will execute against all *Spec.js, and *Spec.coffee files within that directory.

Add Jaspec to your Rakefile

Jaspec is unopinionated as to where you keep your specs. To add a Rake task, put the following in your Rakefile:

require 'jaspec/tasks'

Jaspec::Tasks.new('spec/javascripts') # select your own spec directory to taste.

Now, you can run the following to invoke Jaspec on your specs:

$ rake spec:jaspec

Writing Your Specs

You can format your specs normally:

describe 'A useless spec', ->
  it 'should be useless', ->
    expect(true).toBe true

...but you'll get a LOT more power out of Jaspec if you use AMD-style definitions (RequireJS will include source files that way!)

define ['../myLibrary/foo.js'], (foo) ->
  describe 'foo', ->
    it 'should have a value of 5', ->
      expect(foo.value).toBe 5

You can use these dependencies to load non-AMD compliant JS, and stuff will still work!

define ['../vendor/jQuery.js'], ->
  # do stuff with $

Best of all, since each spec runs in isolation, you can pre-define your dependencies, in order to provide useful stubs and mocks.

define 'foo', -> 'Fake foo'

define ['../thingThatNeedsFoo.js'], (thing) ->
  describe 'thing', ->
    it 'should have a stubbed foo', ->
      expect(thing.foo).toBe 'Fake Foo'

Get testing!

Contributing

  1. Fork it ( https://github.com/gisikw/jaspec/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request