Skip to content

Commit

Permalink
Added CoffeeScript support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Bunsch committed Jun 3, 2011
1 parent fe829ac commit 70f55a6
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/jessie/finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function abs_path(file_or_dir, base_path) {

exports.finder = function() {
this.find = function(files_or_dirs, path) {
var regex = /(_spec|Spec)\.js$/
var regex = /(_spec|Spec)\.(js|coffee)$/
var specs = [];
var finder = this;
files_or_dirs.forEach(function(file_or_dir) {
Expand Down
2 changes: 1 addition & 1 deletion lib/jessie/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ exports.runner = function(args, options, callback) {
specs.forEach(function(spec) { require(spec); })
this.jasmine.reporter = this.reporter
this.jasmine.execute()
}
}
}
17 changes: 17 additions & 0 deletions spec/coffee/animals.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Animal
constructor: (@name) ->

move: (meters) ->
@name + " moved " + meters + "m."

class Snake extends Animal
move: ->
super 5

class Horse extends Animal
move: ->
super 45

exports.Animal = Animal
exports.Snake = Snake
exports.Horse = Horse
File renamed without changes.
12 changes: 12 additions & 0 deletions spec/jessie/coffee_spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe 'Coffee Script support', ->

it 'should pass', ->
'Foo'.should_be 'Foo'

it "should work with external Coffee Script code", ->
animals = require('./../coffee/animals.coffee')
sam = new animals.Snake "Sammy"
tom = new animals.Horse "Tommy"

sam.move().should_be 'Sammy moved 5m.'
tom.move().should_be 'Tommy moved 45m.'
16 changes: 14 additions & 2 deletions spec/jessie/finder_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ describe('jessie.finder', function() {
var finder = new (require('jessie/finder').finder)()

it("should find files if only dir is specified", function() {
finder.find(['spec']).length.should_be(9)
finder.find(['spec']).length.should_be(11)
})

it("should find coffee script files", function() {
var coffees = []
var found = finder.find(['spec'])
for (var i = 0, len = found.length; i < len; i++) {
file = found[i]
if (/\.coffee/.test(file)) {
coffees.push(file)
}
}
coffees.length.should_be(1)
})

it("should find files with Jasmine original spec names like FooSpec.js", function() {
finder.find(['spec/jessie/compatibility']).length.should_be(1)
})

it('leaves non-relative paths alone', function() {
finder.find([path.resolve('spec')]).length.should_be(9)
finder.find([path.resolve('spec')]).length.should_be(11)
});

it("should find files if only files are specified", function() {
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var jessie = require('jessie')
jessie.sugar()

require('coffee-script');

0 comments on commit 70f55a6

Please sign in to comment.