Skip to content

Commit

Permalink
slugify and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffdutton committed Jan 10, 2017
1 parent 34c53c3 commit 08b45cf
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
5 changes: 4 additions & 1 deletion lib/describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var RSVP = require('rsvp');
var path = require('path');
var vcr = require('nock-vcr-recorder');
var wrapMochaFn = require('./wrap-mocha-fn');
var slug = require('slug');

module.exports = wrapMochaFn(describe, function(name, options, callback) {
callback.call(this);
Expand Down Expand Up @@ -43,5 +44,7 @@ function getCassetteName(ctx) {
}
cassettePath.push(ctx.currentTest.title);

return path.join.apply(path, cassettePath);
return path.join.apply(path, cassettePath.map(function(pathPiece) {
return slug(pathPiece).toLowerCase();
}));
}
4 changes: 4 additions & 0 deletions lib/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var RSVP = require('rsvp');
var path = require('path');
var vcr = require('nock-vcr-recorder');
var wrapMochaFn = require('./wrap-mocha-fn');
var slug = require('slug');

module.exports = wrapMochaFn(it, function(name, options, callback) {
var testCtx = this;
Expand Down Expand Up @@ -36,6 +37,9 @@ function getCassetteName(ctx) {
}
}
cassettePath.push(ctx.test.title);
cassettePath = cassettePath.map(function(pathPiece) {
return slug(pathPiece).toLowerCase();
});

return path.join.apply(path, cassettePath);
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
},
"homepage": "https://github.com/poetic/nock-vcr-recorder-mocha",
"dependencies": {
"nock-vcr-recorder": "^0.1.3",
"rsvp": "^3.0.16"
"nock-vcr-recorder": "^0.1.5",
"rsvp": "^3.3.3",
"slug": "^0.9.1"
},
"devDependencies": {
"express": "^3.4.8",
"mocha": "^2.0.1",
"request": "~2.34.0"
"express": "^4.14.0",
"mocha": "^3.2.0",
"request": "^2.79.0"
}
}
6 changes: 3 additions & 3 deletions test/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

var assert = require('assert');
var request = require('request');
var RSVP = require('rsvp');
var vcr = require('../');
var realVcr = require('nock-vcr-recorder');
var slug = require('slug');

describe('config', function() {
it('changes realVcr\'s default config', function() {
Expand All @@ -29,7 +29,7 @@ vcr.describe('config - describe', {
});

after(function() {
var cassette = readCassette('config - describe/excludes github');
var cassette = readCassette(slug('config - describe') + '/' + slug('excludes github'));

assert.equal(cassette.length, 0);
});
Expand All @@ -43,7 +43,7 @@ describe('config - it', function() {
});

after(function() {
var cassette = readCassette('config - it/excludes github');
var cassette = readCassette(slug('config - it') + '/' + slug('excludes github'));

assert.equal(cassette.length, 0);
});
Expand Down
11 changes: 6 additions & 5 deletions test/describe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ var RSVP = require('rsvp');
var request = require('request');
var app = require('./app');
var vcr = require('../');
var slug = require('slug');

vcr.describe('describe', function() {
before(function(done) {
app.listen(4007, done);
});

it('saves a cassette - callback', function(done) {
it('slugifies a cassette - callback', function(done) {
request('http://localhost:4007/test', done);
});

it('saves a cassette - promise', function() {
it('slugifies a cassette - Promise', function() {
return RSVP.denodeify(request)('http://localhost:4007/test');
});

Expand All @@ -24,9 +25,9 @@ vcr.describe('describe', function() {
});

after(function() {
assertCassette('describe/saves a cassette - callback');
assertCassette('describe/saves a cassette - promise');
assertNotCassette('describe/doesnt save with no requests');
assertCassette('describe/' + slug('slugifies a cassette - promise'));
assertCassette('describe/' + slug('slugifies a cassette - callback'));
assertNotCassette(slug('describe/doesnt save with no requests'));
});
});

12 changes: 7 additions & 5 deletions test/it-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ var RSVP = require('rsvp');
var request = require('request');
var app = require('./app');
var vcr = require('../');
var slug = require('slug');

describe('it', function() {
before(function(done) {
app.listen(4006, done);
});

vcr.it('saves a cassette - callback', function(done) {
vcr.it('slugifies a cassette - callback', function(done) {
request('http://localhost:4006/test', done);
});

vcr.it('saves a cassette - promise', function() {
vcr.it('slugifies a cassette - Promise', function() {
return RSVP.denodeify(request)('http://localhost:4006/test');
});

Expand All @@ -24,9 +25,10 @@ describe('it', function() {
});

after(function() {
assertCassette('it/saves a cassette - callback');
assertCassette('it/saves a cassette - promise');
assertNotCassette('it/doesnt save with no requests');
console.log('after');
assertCassette('it/' + slug('slugifies a cassette - callback'));
assertCassette('it/' + slug('slugifies a cassette - promise'));
assertNotCassette(slug('it/doesnt save with no requests'));
});
});

0 comments on commit 08b45cf

Please sign in to comment.