Sha256: 9b42a94e51e5baaf04d90283b6e18b5873eff786a1b98335cf7d055e34670937

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 Bytes

Contents

require 'spec_helper'

describe Waddup::Extension::System do

  let(:dummy) {
    Class.new do
      extend Waddup::Extension::System
    end
  }

  describe '#os' do
    it 'identifies the operating system' do
      stub_const('RbConfig::CONFIG', 'host_os' => 'linux')
      expect(dummy.os).to eq 'linux'
    end

    it 'is cached' do
      stub_const('RbConfig::CONFIG', 'host_os' => 'foo')
      expect(dummy.os).to eq 'foo'

      stub_const('RbConfig::CONFIG', 'host_os' => 'foobar')
      expect(dummy.os).to eq 'foo'
    end
  end

  describe '#osx?' do
    context 'when on OSX' do
      it 'returns true' do
        stub_const('RbConfig::CONFIG', 'host_os' => 'darwin')
        expect(dummy).to be_osx
      end
    end

    context 'when on other operating systems' do
      it 'returns false' do
        stub_const('RbConfig::CONFIG', 'host_os' => 'linux')
        expect(dummy).not_to be_osx
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
waddup-0.2.2 spec/waddup/extensions/system_spec.rb
waddup-0.2.1 spec/waddup/extensions/system_spec.rb
waddup-0.2.0 spec/waddup/extensions/system_spec.rb
waddup-0.1.0 spec/waddup/extensions/system_spec.rb
waddup-0.0.2 spec/waddup/extensions/system_spec.rb