Sha256: 0a9d47e9baa343462b2c3205c2b4ec7494dd6ebb8fc5697385f52de8b42075db

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'
require 'command_kit/os'

describe CommandKit::OS do
  class TestOS
    include CommandKit::OS
  end

  subject { TestOS.new }

  describe "#linux?" do
    context "when RUBY_PLATFORM contains 'linux'" do
      before { stub_const('RUBY_PLATFORM','x86_64-linux') }

      it { expect(subject.linux?).to be(true) }
    end

    context "when RUBY_PLATFORM does not contain 'linux'" do
      before { stub_const('RUBY_PLATFORM','aarch64-darwin') }

      it { expect(subject.linux?).to be(false) }
    end
  end

  describe "#macos?" do
    context "when RUBY_PLATFORM contains 'darwin'" do
      before { stub_const('RUBY_PLATFORM','aarch64-darwin') }

      it { expect(subject.macos?).to be(true) }
    end

    context "when RUBY_PLATFORM does not contain 'darwin'" do
      before { stub_const('RUBY_PLATFORM','mswin') }

      it { expect(subject.macos?).to be(false) }
    end
  end

  describe "#windows?" do
    it "must call Gem.win_platform?" do
      expect(Gem).to receive(:win_platform?)

      subject.windows?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
command_kit-0.1.0 spec/os_spec.rb