From e6a982d92c805746b68769688341c1e35e379239 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 9 Dec 2014 13:42:49 -0400 Subject: [PATCH] Fix resin/helpers spec os dependant paths --- lib/resin/helpers/helpers.spec.coffee | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/resin/helpers/helpers.spec.coffee b/lib/resin/helpers/helpers.spec.coffee index 7f79e9dd..0caf2303 100644 --- a/lib/resin/helpers/helpers.spec.coffee +++ b/lib/resin/helpers/helpers.spec.coffee @@ -1,6 +1,8 @@ +os = require('os') chai = require('chai') chai.use(require('chai-string')) expect = chai.expect +path = require('path') helpers = require('./helpers') describe 'Helpers:', -> @@ -8,10 +10,10 @@ describe 'Helpers:', -> describe '#prefixObjectWithPath()', -> it 'should add the path to every value', -> - prefix = '/resin' + prefix = "#{path.sep}resin" object = first: 'first' - second: './second' + second: ".#{path.sep}second" result = helpers.prefixObjectValuesWithPath(prefix, object) @@ -19,12 +21,20 @@ describe 'Helpers:', -> expect(value).to.startsWith(prefix) it 'should not add the prefix if the paths are absolute', -> - prefix = '/resin' - object = - first: '/first' - second: '/home/second' - third: '/usr/share/resin' - fourth: '/' + prefix = "#{path.sep}resin" + + if os.platform() is 'win32' + object = + first: 'C:\\first' + second: 'C:\\Users\\me' + third: 'C:\\' + + else + object = + first: '/first' + second: '/home/second' + third: '/usr/share/resin' + fourth: '/' result = helpers.prefixObjectValuesWithPath(prefix, object) expect(result).to.deep.equal(object)