Permalink
Browse files

Switch to jasmine for testing, start cleaning up tests.

  • Loading branch information...
1 parent 996bc81 commit 5205510dc9ef820429d23167ed8f432cf7fd611c @toots committed Jan 9, 2013
Showing with 37 additions and 37 deletions.
  1. +7 −9 Cakefile
  2. +3 −0 package.json
  3. +27 −20 spec/apps.spec.coffee
  4. +0 −8 test/releases.coffee
View
@@ -1,8 +1,10 @@
-option '-k', '--key [KEY]', 'Set heroku client key for tests.'
-option '-a', '--app [APP]', 'Set heroku app for tests.'
+{exec, spawn} = require "child_process"
+
+system = (command, args) ->
+ spawn command, args, stdio: "inherit"
task 'build', 'Compile coffee scripts into plain Javascript files', ->
- child = require("child_process").exec "coffee -c -o lib src/*.coffee", (err, stdout, stderr) ->
+ child = exec "coffee -c -o lib src/*.coffee", (err, stdout, stderr) ->
if err?
console.error "Error :"
console.dir err
@@ -11,9 +13,5 @@ task 'build', 'Compile coffee scripts into plain Javascript files', ->
else
console.log "Done!"
-task 'test', 'Run the test suite', (args) ->
- key = args.key || process.env["HEROKU_KEY"]
- app = args.app || process.env["HEROKU_TEST_APP"]
-
- (require "./test/releases") key, app
-
+task 'spec', 'Run the spec tests', ->
+ system "jasmine-node", ["--coffee", "./spec"]
View
@@ -20,6 +20,9 @@
"test":"./test",
"src":"./src"
},
+ "scripts": {
+ "test": "cake spec"
+ },
"engine": {"node": ">= 0.4.7", "npm": "1"},
"licences":
[
View
@@ -1,38 +1,45 @@
describe "Apps", ->
- {Apps} = require "../src/apps"
- apps = null
+ {Heroku} = require "../src/heroku"
beforeEach ->
- apps = new Apps
- apps.request = (arg, callback) -> return
- spyOn(apps, 'request')
+ @heroku = new Heroku
+ key : "deadbeef"
+
+ spyOn @heroku, "request"
it "should be able to create a properly structured JSON file from params", ->
expected =
app :
name : "the-test-case"
- actual = apps.app_params(name: "the-test-case")
- expect(actual).toEqual(expected)
+
+ actual = @heroku.app_params
+ name: "the-test-case"
+
+ expect(actual).toEqual expected
it "should be able to send a properly constructed JSON POST request to create", ->
- apps.post_app {name: "the-test-case"}, () -> return
- expected =
+ fn = ->
+
+ @heroku.post_app { name: "the-test-case" }, fn
+
+ expect(@heroku.request).toHaveBeenCalledWith {
expects : 202
method : "POST"
path : "/apps"
query :
- app :
- name: "the-test-case"
- expect(apps.request).toHaveBeenCalled()
- expect(apps.request.mostRecentCall.args[0]).toEqual(expected)
+ app :
+ name : "the-test-case"
+ }, fn
it "should be to send an update request to change the name of an app", ->
- apps.put_app 'the-test-case', {name: 'the-test-case-2'}, () -> return
- expected =
+ fn = ->
+
+ @heroku.put_app "the-test-case", { name: "the-test-case-2" }, fn
+
+ expect(@heroku.request).toHaveBeenCalledWith {
method : "PUT"
path : "/apps/the-test-case"
- query :
- app :
- name : 'the-test-case-2'
- expect(apps.request).toHaveBeenCalled()
- expect(apps.request.mostRecentCall.args[0]).toEqual(expected)
+ query :
+ app :
+ name : "the-test-case-2"
+ }, fn
View
@@ -1,8 +0,0 @@
-{Heroku} = require "../lib/heroku"
-
-module.exports = (key, app) ->
- client = new Heroku { key: key }
-
- client.get_releases app, (err, ret) ->
- console.dir err
- console.dir ret

0 comments on commit 5205510

Please sign in to comment.