Skip to content

Commit

Permalink
Get the tests a bit further.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeiklejohn committed Sep 11, 2011
1 parent 98a37ba commit 1da0add
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 18 deletions.
51 changes: 40 additions & 11 deletions spec/controllers/repositories_spec.coffee
@@ -1,9 +1,11 @@
vows = require('../spec_helper').vows
client = require('../spec_helper').client
tobi = require('../spec_helper').tobi
assert = require('../spec_helper').assert
jsonHeaders = require('../spec_helper').headers.jsonHeaders
Repository = require('../../models/repository').Repository
vows = require('../spec_helper').vows
client = require('../spec_helper').client
tobi = require('../spec_helper').tobi
assert = require('../spec_helper').assert
should = require('../spec_helper').should
jsonHeaders = require('../spec_helper').headers.jsonHeaders
Repository = require('../../models/repository').Repository
RepositoryFactory = require('../spec_helper').factories.Repository

vows
.describe('repositories')
Expand All @@ -14,9 +16,14 @@ vows
.addBatch

'with a repository':
topic: ->
attributes =
name: "testrepo"
ownerName: "testuser"
RepositoryFactory.create attributes, @callback

'when requesting the repository list':
topic: (repository) ->
topic: ->
tobi.get('/repositories', @callback)

'should respond with a 200 ok': (response, $) ->
Expand All @@ -30,9 +37,14 @@ vows
.addBatch

'with a repository':
topic: ->
attributes =
name: "testrepo"
ownerName: "testuser"
RepositoryFactory.create attributes, @callback

'when requesting the repository list by name':
topic: (repository) ->
topic: ->
tobi.get('/repositories/testrepo', @callback)

'should respond with a 200 ok': (response, $) ->
Expand All @@ -46,23 +58,40 @@ vows
.addBatch

'with a repository':
topic: ->
attributes =
name: "testrepo"
ownerName: "testuser"
RepositoryFactory.create attributes, @callback

'when requesting one repository':
topic: (repository) ->
topic: ->
tobi.get('/repositories/testuser/testrepo', @callback)

'should respond with a 200 ok': (response, $) ->
response.should.have.status(200)

'should return a of repositories': (response, $) ->
'should return a one repositories': (response, $) ->
response.body.should.be.an.instanceof(Object)

'should contain the repository we just created': 'pending'

.addBatch

'with a repository':
topic: ->
attributes =
name: "testrepo"
ownerName: "testuser"
RepositoryFactory.create attributes, @callback

'when deleting repository': 'pending'
'when deleting repository':
topic: ->
tobi.get('/repositories/testuser/deleterepo', @callback)

'should respond with a 200 ok': (response, $) ->
response.should.have.status(200)

'should contain the repository we just created': 'pending'

.export(module)
54 changes: 48 additions & 6 deletions spec/controllers/repositories_spec.js
@@ -1,17 +1,27 @@
(function() {
var Repository, assert, client, jsonHeaders, tobi, vows;
var Repository, RepositoryFactory, assert, client, jsonHeaders, should, tobi, vows;
vows = require('../spec_helper').vows;
client = require('../spec_helper').client;
tobi = require('../spec_helper').tobi;
assert = require('../spec_helper').assert;
should = require('../spec_helper').should;
jsonHeaders = require('../spec_helper').headers.jsonHeaders;
Repository = require('../../models/repository').Repository;
RepositoryFactory = require('../spec_helper').factories.Repository;
vows.describe('repositories').addBatch({
'when creating a new repository': 'pending'
}).addBatch({
'with a repository': {
topic: function() {
var attributes;
attributes = {
name: "testrepo",
ownerName: "testuser"
};
return RepositoryFactory.create(attributes, this.callback);
},
'when requesting the repository list': {
topic: function(repository) {
topic: function() {
return tobi.get('/repositories', this.callback);
},
'should respond with a 200 ok': function(response, $) {
Expand All @@ -25,8 +35,16 @@
}
}).addBatch({
'with a repository': {
topic: function() {
var attributes;
attributes = {
name: "testrepo",
ownerName: "testuser"
};
return RepositoryFactory.create(attributes, this.callback);
},
'when requesting the repository list by name': {
topic: function(repository) {
topic: function() {
return tobi.get('/repositories/testrepo', this.callback);
},
'should respond with a 200 ok': function(response, $) {
Expand All @@ -40,22 +58,46 @@
}
}).addBatch({
'with a repository': {
topic: function() {
var attributes;
attributes = {
name: "testrepo",
ownerName: "testuser"
};
return RepositoryFactory.create(attributes, this.callback);
},
'when requesting one repository': {
topic: function(repository) {
topic: function() {
return tobi.get('/repositories/testuser/testrepo', this.callback);
},
'should respond with a 200 ok': function(response, $) {
return response.should.have.status(200);
},
'should return a of repositories': function(response, $) {
'should return a one repositories': function(response, $) {
return response.body.should.be.an["instanceof"](Object);
},
'should contain the repository we just created': 'pending'
}
}
}).addBatch({
'with a repository': {
'when deleting repository': 'pending'
topic: function() {
var attributes;
attributes = {
name: "testrepo",
ownerName: "testuser"
};
return RepositoryFactory.create(attributes, this.callback);
},
'when deleting repository': {
topic: function() {
return tobi.get('/repositories/testuser/deleterepo', this.callback);
},
'should respond with a 200 ok': function(response, $) {
return response.should.have.status(200);
},
'should contain the repository we just created': 'pending'
}
}
})["export"](module);
}).call(this);
10 changes: 10 additions & 0 deletions spec/spec_helper.coffee
Expand Up @@ -2,6 +2,7 @@ exports.app = app = require('../config/app').app

exports.vows = require 'vows'
exports.assert = require 'assert'
exports.should = require 'should'

exports.zombie = require 'zombie'
exports.zombie.browser = new exports.zombie.Browser
Expand All @@ -17,3 +18,12 @@ exports.tobi.get = (path, callback) ->

exports.headers = {}
exports.headers.jsonHeaders = { 'Content-Type': 'application/json' }

Repository = require('../models/repository').Repository

exports.factories = {}
exports.factories.Repository = {}
exports.factories.Repository.create = (attributes, callback) ->
repositories = new Repository attributes
repositories.save(callback)
return
11 changes: 10 additions & 1 deletion spec/spec_helper.js
@@ -1,8 +1,9 @@
(function() {
var app;
var Repository, app;
exports.app = app = require('../config/app').app;
exports.vows = require('vows');
exports.assert = require('assert');
exports.should = require('should');
exports.zombie = require('zombie');
exports.zombie.browser = new exports.zombie.Browser({
debug: false,
Expand All @@ -20,4 +21,12 @@
exports.headers.jsonHeaders = {
'Content-Type': 'application/json'
};
Repository = require('../models/repository').Repository;
exports.factories = {};
exports.factories.Repository = {};
exports.factories.Repository.create = function(attributes, callback) {
var repositories;
repositories = new Repository(attributes);
repositories.save(callback);
};
}).call(this);

0 comments on commit 1da0add

Please sign in to comment.