Sha256: 8d3d2f610903e5035dd8132d2da3ef18ccbd4df84928da5baa09e97183754e7b

Contents?: true

Size: 1.63 KB

Versions: 7

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

module Wrapp
  describe AppInfo do
    let(:app) { AppInfo.new('Info.plist') }

    describe '#full_name' do
      it 'includes the downcased name and version without spaces' do
        app.stub(:name).and_return("Chunky\t Bacon")
        app.stub(:version).and_return('1.2.3')
        expect(app.full_name).to eq('chunky_bacon_1.2.3')
      end
    end

    describe '#name' do
      it 'returns the app name' do
        app.should_receive(:get_property).
          with('CFBundleName').
          and_return('Chunky Bacon')
        expect(app.name).to eq('Chunky Bacon')
      end
    end

    describe '#version' do
      it 'returns the app version' do
        app.should_receive(:get_property).
          with('CFBundleShortVersionString').
          and_return('0.4.2')
        expect(app.version).to eq('0.4.2')
      end
    end

    describe '#properties' do
      it 'returns the app properties as hash' do
        Plist.should_receive(:parse_xml).with('Info.plist').
          and_return(:plist_as_hash)
        expect(app.send(:properties)).to eq(:plist_as_hash)
      end
    end

    describe '#get_property' do
      context 'with existing property' do
        it 'returns the striped property' do
          app.stub(:properties).and_return({})
          expect { 
            app.get_property('Chunky')
          }.to raise_error(/no property found: chunky/i)
        end
      end

      context 'with missing property' do
        it 'raises an error' do
          app.stub(:properties).and_return({ 'Chunky' => ' Bacon ' })
          expect(app.get_property('Chunky')).to eq('Bacon')
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wrapp-0.2.3 spec/wrapp/app_info_spec.rb
wrapp-0.2.2 spec/wrapp/app_info_spec.rb
wrapp-0.2.1 spec/wrapp/app_info_spec.rb
wrapp-0.2.0 spec/wrapp/app_info_spec.rb
wrapp-0.1.2 spec/wrapp/app_info_spec.rb
wrapp-0.1.1-x86_64-darwin-12 spec/wrapp/app_info_spec.rb
wrapp-0.1.0 spec/wrapp/app_info_spec.rb