Sha256: c69985323d5fa893a1612810e197b4f1a42ea4b57bcbd9c34c9c9e46ec421f92

Contents?: true

Size: 1.99 KB

Versions: 6

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

require 'rocket_fuel/precheck/command_line_tool_check'

require 'fakefs'
require 'fakefs/spec_helpers'
require 'fileutils'

describe RocketFuel::Precheck::CommandLineToolCheck do
  include FakeFS::SpecHelpers

  before(:each) do
    FileUtils.mkdir_p(File.dirname(path))
  end

  let(:path) { RocketFuel::Precheck::CommandLineToolCheck::TEN_NINE_RECEIPT_PATH }
  [
    '10.9.4',
    '10.10'
  ].each do |os_vers|
    context "os x #{os_vers}" do
      let(:os) { RocketFuel::OperatingSystem.new('darwin', os_vers)}
      before(:each) do
        RocketFuel::SystemDetails.stubs(:os).returns(os)
      end

      let(:check) { RocketFuel::Precheck::CommandLineToolCheck.new }
      it 'is ok if the receipt file is found' do
        FileUtils.touch(path)
        expect(check).to be_ok
      end

      it 'is not ok if the receipt is not found' do
        FileUtils.rm_f(path) if FileTest.exist?(path)
        expect(check).to_not be_ok
      end

      it 'has a failure message if the receipt is not found' do
        FileUtils.rm_f(path) if FileTest.exist?(path)
        expect(check.run.message).to match(/not found/i)
      end
    end
  end

  context 'os x 10.8' do
    before(:each) do
      os = RocketFuel::OperatingSystem.new('darwin', '10.8.4')
      RocketFuel::SystemDetails.stubs(:os).returns(os)
    end

    let(:check) { RocketFuel::Precheck::CommandLineToolCheck.new }
    let(:path) { RocketFuel::Precheck::CommandLineToolCheck::DEFAULT_RECEIPT_PATH }

    it 'is ok if the receipt file is found' do
      FileUtils.touch(path)
      expect(check).to be_ok
    end

    it 'is not ok if the receipt is not found' do
      FileUtils.rm_f(path) if FileTest.exist?(path)
      expect(check).to_not be_ok
    end
  end

  it 'does not check for operating systems other than the mac' do
    check = RocketFuel::Precheck::CommandLineToolCheck.new
    os = RocketFuel::OperatingSystem.new('linux', '2.6')
    RocketFuel::SystemDetails.stubs(:os).returns(os)
    expect(check).to_not be_check
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rocket_fuel-0.0.6 spec/rocket_fuel/precheck/command_line_tool_check_spec.rb
rocket_fuel-0.0.5 spec/rocket_fuel/precheck/command_line_tool_check_spec.rb
rocket_fuel-0.0.4 spec/rocket_fuel/precheck/command_line_tool_check_spec.rb
rocket_fuel-0.0.3 spec/rocket_fuel/precheck/command_line_tool_check_spec.rb
rocket_fuel-0.0.2 spec/rocket_fuel/precheck/command_line_tool_check_spec.rb
rocket_fuel-0.0.1 spec/rocket_fuel/precheck/command_line_tool_check_spec.rb