Skip to content

Instantly share code, notes, and snippets.

@LinuxBozo
Created January 23, 2015 16:34
Show Gist options
  • Save LinuxBozo/88d855c2c0271caab721 to your computer and use it in GitHub Desktop.
Save LinuxBozo/88d855c2c0271caab721 to your computer and use it in GitHub Desktop.
var engine = require('../engine'),
rewiredEngine = rewire('../engine'),
http = require('http'),
shmock = require('shmock'),
port = '10000',
mockAPIURL = 'http://localhost:'+port,
mockYEAR = '2013';
describe('Engine', function() {
var mockAPI;
before(function() {
mockAPI = shmock(port);
});
beforeEach(function() {
engine.setAPIURL(mockAPIURL);
engine.setRuleYear(mockYEAR);
mockAPI.clean();
});
describe('Make sure mockAPI is up', function() {
it('should allow route define and respond with 200', function(done) {
var handler = mockAPI.get('/foo').reply(200, 'bar');
http.get(mockAPIURL+'/foo', function(resp) {
handler.done();
expect(resp.statusCode).to.be(200);
done();
});
});
it('should have fulfilled route in previus test and now respond with 404', function(done) {
http.get(mockAPIURL+'/foo', function(resp) {
expect(resp.statusCode).to.be(404);
done();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment