diff --git a/lib/drive/osx.coffee b/lib/drive/osx.coffee index 2e317cf3..71ceea31 100644 --- a/lib/drive/osx.coffee +++ b/lib/drive/osx.coffee @@ -29,7 +29,7 @@ exports.list = (callback) -> return { device: "/dev/#{device}" - size: "#{size}#{sizeMeasure}" + size: "#{size} #{sizeMeasure}" description: row.join(' ') } diff --git a/lib/drive/osx.spec.coffee b/lib/drive/osx.spec.coffee new file mode 100644 index 00000000..4ba5f5a0 --- /dev/null +++ b/lib/drive/osx.spec.coffee @@ -0,0 +1,49 @@ +chai = require('chai') +expect = chai.expect +sinon = require('sinon') +chai.use(require('sinon-chai')) +childProcess = require('child_process') +osx = require('./osx') + +describe 'Drive OSX:', -> + + describe 'given correct output from diskdrive', -> + + beforeEach -> + @childProcessStub = sinon.stub(childProcess, 'exec') + @childProcessStub.yields null, ''' + /dev/disk0 + #: TYPE NAME SIZE IDENTIFIER + 0: GUID_partition_scheme *750.2 GB disk0 + 1: EFI EFI 209.7 MB disk0s1 + 2: Apple_CoreStorage 749.3 GB disk0s2 + 3: Apple_Boot Recovery HD 650.0 MB disk0s3 + /dev/disk1 + #: TYPE NAME SIZE IDENTIFIER + 0: Apple_HFS Macintosh HD *748.9 GB disk1 + Logical Volume on disk0s2 + 3D74D961-80FB-4DB1-808F-8B5800C53E3A + Unlocked Encrypted + ''', undefined + + afterEach -> + @childProcessStub.restore() + + it 'should extract the necessary information', (done) -> + osx.list (error, stdout) -> + expect(error).to.not.exist + + expect(stdout).to.deep.equal [ + { + device: '/dev/disk0' + description: 'GUID_partition_scheme' + size: '*750.2 GB' + } + { + device: '/dev/disk1' + description: 'Apple_HFS Macintosh HD' + size: '*748.9 GB' + } + ] + + return done()