Sha256: 6c3a61e55fdee9a3e70201e4993746091f299cba2d6696b05a42c8f34a57c3cb

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

module Wrapp
  describe DMGBuilder do
    let(:dmg) { DMGBuilder.new('Chunky Bacon.app') }
    let(:app) { double('app') }

    before do
      DMGBuilder.any_instance.stub(:system)
    end

    describe '.run' do
      it 'creates the dmg' do
        DMGBuilder.stub(:new).and_return(dmg)
        dmg.should_receive(:create) #TODO: Fix nil warning!
        DMGBuilder.run
      end
    end

    describe '#create' do
      it 'creates the dmg and directory' do
        dmg.should_receive(:create_dmg)
        dmg.create
      end
    end

    describe '#create_dmg' do
      it 'creates the dmg by hdiutil' do
        dmg.should_receive(:app_path).and_return('Chunky.app')
        dmg.should_receive(:dmg_path).and_return('bacon.dmg')
        dmg.should_receive(:system).
          with("hdiutil create 'bacon.dmg' -srcfolder 'Chunky.app'")
        dmg.send(:create_dmg)
      end
    end

    describe '#app_path' do
      it 'returns the path to the app' do
        expect(dmg.app_path).to eq('Chunky Bacon.app')
      end
    end

    describe '#dmg_path' do
      it 'returns the dmg_filename' do
        dmg.should_receive(:dmg_filename).and_return('chunky_bacon.dmg')
        expect(dmg.send(:dmg_path)).to eq('chunky_bacon.dmg')
      end
    end

    describe '#dmg_filename' do
      it 'includes the full app name' do
        app.should_receive(:full_name).and_return('chunky_bacon_0.4.2')
        dmg.stub(:app).and_return(app)
        expect(dmg.send(:dmg_filename)).to eq('chunky_bacon_0.4.2.dmg')
      end
    end

    describe '#app' do
      it 'creates a cached app_info instance' do
        dmg.should_receive(:plist).and_return('Info.plist')
        AppInfo.should_receive(:new).once.with('Info.plist').and_return(app)
        expect(dmg.send(:app)).to eq(app)
      end
    end

    describe '#plist' do
      it 'returns the app info plist path' do
        expect(dmg.send(:plist)).to eq('Chunky Bacon.app/Contents/Info.plist')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wrapp-0.1.2 spec/wrapp/dmg_builder_spec.rb
wrapp-0.1.1-x86_64-darwin-12 spec/wrapp/dmg_builder_spec.rb
wrapp-0.1.0 spec/wrapp/dmg_builder_spec.rb