Skip to content
Browse files

Cashrc tests won't wipe out your configurations

  • Loading branch information...
1 parent 6e953ce commit f6d688dd567a5ce52ae7cae17e56a3bcfe8dc53f @nfischer nfischer committed
Showing with 24 additions and 7 deletions.
  1. +24 −7 test/index.js
View
31 test/index.js
@@ -6,27 +6,44 @@ const $ = require('shelljs');
const delimiter = require('./../dist/delimiter.js');
let cash;
+let cashrcCopy;
+let cashrcPath;
describe('cash', function () {
- before(function () {
- 'touch fizzlecrumbs'.to(`${delimiter.getHomeDir()}/.cashrc`);
- cash = require('..');
- });
-
it('should export properly', function () {
should.exist(require('..'));
});
describe('.cashrc', function () {
+ before(function () {
+ cashrcPath = `${delimiter.getHomeDir()}/.cashrc`;
+ cashrcCopy = `${cashrcPath}_${String(Math.random())}`;
+ if ($.test('-f', cashrcPath)) {
+ $.mv(cashrcPath, cashrcCopy);
+ if ($.error()) {
+ console.error('warning: unable to save your cashrc file');
+ }
+ }
+ 'touch fizzlecrumbs'.to(cashrcPath);
+ cash = require('..');
+ });
+
after(function () {
- $.rm('-rf', '.cashrc');
+ if ($.test('-f', cashrcCopy)) {
+ $.mv(cashrcCopy, cashrcPath);
+ if ($.error()) {
+ console.error('warning: unable to restore your cashrc file');
+ }
+ } else {
+ $.rm('-f', cashrcPath);
+ }
$.rm('-rf', 'fizzlecrumbs');
});
// I think this is an import problem between test
// problems.
it.skip('should load a .cashrc file', function () {
- $.test('-e', 'fizzlecrumbs').should.equal(true);
+ $.test('-f', 'fizzlecrumbs').should.equal(true);
});
});

0 comments on commit f6d688d

Please sign in to comment.
Something went wrong with that request. Please try again.