Sha256: fee6455a6a18b9cd5fc2f6ad3b04079b9ea278c93b9cb8f12c8ec8197ec5a728

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

module Maid
  describe Platform do
    def stub_host_os(value)
      allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return(value)
    end

    describe 'determining the host OS' do
      it 'delegates to RbConfig' do
        stub_host_os('foo')
        expect(subject.host_os).to eq('foo')
      end
    end

    context 'when running on Ubuntu' do
      before do
        stub_host_os('linux-gnu')
      end

      it 'is identified as Linux' do
        expect(subject.linux?).to be(true)
      end

      it 'is not identified as OS X' do
        expect(subject.osx?).to be(false)
      end

      it 'locate is "locate"' do
        expect(Platform::Commands.locate).to match(/locate/)
      end
    end

    context 'when running on Mac OS X' do
      before do
        stub_host_os('darwin10.0')
      end

      it 'is not identified as Linux' do
        expect(subject.linux?).to be(false)
      end

      it 'is identified as OS X' do
        expect(subject.osx?).to be(true)
      end

      it 'locate is "mdfind"' do
        expect(Platform::Commands.locate).to match(/mdfind/)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
maid-0.10.0 spec/lib/maid/platform_spec.rb
maid-0.10.0.pre.alpha.3 spec/lib/maid/platform_spec.rb
maid-0.10.0.pre.alpha.2 spec/lib/maid/platform_spec.rb
maid-0.10.0.pre.alpha.1 spec/lib/maid/platform_spec.rb