Skip to content

Commit

Permalink
Removed dead method.
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-jack committed Nov 8, 2014
1 parent 41b5db1 commit 3cef3df
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 123 deletions.
34 changes: 1 addition & 33 deletions lib/hosting/startServerFluent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,6 @@ var performTest = function * (expressApp, testDefinition) {
yield * testDefinition.runAgainst(this.server);
};

// TODO - Move to diff file
var runTestAndClose = function (testDefinition, done) {
var self = this;
var deferred = Q.defer();

Q.spawn(function *() {
var exception;

try {
yield * self.performTest(self.expressApp, testDefinition);

deferred.resolve();
} catch (e) {
exception = e;

deferred.reject(e);
} finally {
if (this.server) {
yield expressServerCloser.close(self.server);
}
}

if (done) {
done(exception, null);
}
});

return deferred.promise;
}

// TODO - Move to diff file
var runTest = function (testDefinition, done) {
var self = this;
Expand Down Expand Up @@ -102,9 +72,7 @@ var proto = {
runTest: runTest,

performTest: performTest,
close: close,

runTestAndClose: runTestAndClose
close: close
}

var startServerFluent = function (expressApp) {
Expand Down
49 changes: 26 additions & 23 deletions spec/integration/GET/get_expectCacheForever_spec.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
var testResources = require('require-namespace').testResources;
var resource = testResources.require('entryPointCreator');
var express = require('express');
var testUtil = require('./../testUtil');

describe("get cache forever - ", function() {
describe('when you test a get request and resource returns json which can be cached for twenty years publically', function() {
var testBuilder;

beforeEach(function() {
var app = express();
var resourceTest = require('../../../index');
var fixture = require('../../testFixture')
var assert = fixture.assert;

app.get('/cacheForever', function(req, res){
var twentyYears = 20 * 365 * 24 * 60 * 60;
res.header('Cache-Control', 'public, max-age=' + twentyYears)
res.send({ name: 'fido' });
});
var express = require('express');
var superAgent = require('superagent');

testBuilder = resource(app).get('/cacheForever');
});
var testUtil = require('./../testUtil');
var startServer = fixture.testResources.startServerFluent;

it('should pass if your expectation matches', function(done) {
testBuilder
.expectCachedForever('public')
.run(testUtil.assertNoError(done));
describe('when you test a get request and resource returns json which can be cached for twenty years publically', function () {
var testBuilder;

beforeEach(function () {
var app = express();

app.get('/cacheForever', function (req, res) {
var twentyYears = 20 * 365 * 24 * 60 * 60;
res.header('Cache-Control', 'public, max-age=' + twentyYears)
res.send({ name: 'fido' });
});
})

testBuilder = resource(app).get('/cacheForever');
});

it('should pass if your expectation matches', function (done) {
testBuilder
.expectCachedForever('public')
.run(testUtil.assertNoError(done));
});
});
132 changes: 65 additions & 67 deletions spec/integration/GET/get_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,84 @@ var superAgent = require('superagent');
var testUtil = require('./../testUtil');
var startServer = fixture.testResources.startServerFluent;

describe("get - ", function() {
describe('when you test a get request', function() {
describe('and resource returns cacheable json', function () {
var server;
var request;
describe('when you test a get request', function() {
describe('and resource returns cacheable json', function () {
var server;
var request;

before(function () {
var app = express();
before(function () {
var app = express();

app.get('/get', function (req, res) {
res.header('Cache-Control', 'private, max-age=300')
res.send({ name: 'fido' });
});
app.get('/get', function (req, res) {
res.header('Cache-Control', 'private, max-age=300')
res.send({ name: 'fido' });
});

server = startServer(app);
})
server = startServer(app);
})

beforeEach(function () {
request = superAgent.get('/get')
});
beforeEach(function () {
request = superAgent.get('/get')
});

after(function () {
server.close();
})
after(function () {
server.close();
})

it('should pass if your expectations are correct', function () {
return resourceTest(request)
.expectBody({ name: 'fido' })
.expectCached("private", 5)
.run(server)
});
it('should pass if your expectations are correct', function () {
return resourceTest(request)
.expectBody({ name: 'fido' })
.expectCached("private", 5)
.run(server)
});

it('should pass if your expectations are correct', function () {
return resourceTest(request)
.expectBody({ name: 'fido' })
.expectCached("private", 5)
.run(server)
});
it('should pass if your expectations are correct', function () {
return resourceTest(request)
.expectBody({ name: 'fido' })
.expectCached("private", 5)
.run(server)
});

it('should pass if your expectations are correct2', function (done) {
resourceTest(request)
.expectBody({ name: 'fido' })
.expectCached("private", 5)
.run(server, done)
});
it('should pass if your expectations are correct2', function (done) {
resourceTest(request)
.expectBody({ name: 'fido' })
.expectCached("private", 5)
.run(server, done)
});

it('should fail if caching expectation is incorrect', function () {
return assert.isRejected(resourceTest(request)
.expectCached("private", 10)
.run(server));
});
it('should fail if caching expectation is incorrect', function () {
return assert.isRejected(resourceTest(request)
.expectCached("private", 10)
.run(server));
});

it('should fail if body expectation is incorrect', function () {
return assert.isRejected(resourceTest(request)
.expectBody({ name: 'spot' })
.run(server));
});
it('should fail if body expectation is incorrect', function () {
return assert.isRejected(resourceTest(request)
.expectBody({ name: 'spot' })
.run(server));
});

it('should fail if response code is not expected', function () {
return assert.isRejected(resourceTest(request)
.expectStatus(400)
.run(server), /The status should have been 400./);
});
it('should fail if response code is not expected', function () {
return assert.isRejected(resourceTest(request)
.expectStatus(400)
.run(server), /The status should have been 400./);
});

it.skip('should fail if you expect it to be cached forever', function () {
debugger;
var api = resourceTest(request).expectCachedForever();
return assert.isRejected(api
.run(server), /the body did not match/);
});
it.skip('should fail if you expect it to be cached forever', function () {
debugger;
var api = resourceTest(request).expectCachedForever();
return assert.isRejected(api
.run(server), /the body did not match/);
});

it.skip('should work if body is empty but we expected that', function () {
});

it.skip('should fail if you expect no caching but resource is cached', function () {
});
})
it.skip('should work if body is empty but we expected that', function () {
});

describe('and resource returns something other than JSON', function () {
it('should fail');
it.skip('should fail if you expect no caching but resource is cached', function () {
});
})

describe('and resource returns something other than JSON', function () {
it('should fail');
});
});
});

0 comments on commit 3cef3df

Please sign in to comment.