Sha256: d6cdaa579435f5b218369ace528db56a13e566873c747f165efde01d2796f596

Contents?: true

Size: 1.64 KB

Versions: 17

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'
require 'facter/application'

describe Facter::Application do
  describe '.parse' do
    it 'returns an empty hash when given no options' do
      Facter::Application.parse([]).should == {}
      Facter::Application.parse(['architecture', 'kernel']).should == {}
    end

    [:yaml, :json, :trace].each do |option_key|
      it "sets options[:#{option_key}] when given --#{option_key}" do
        options = Facter::Application.parse(["--#{option_key}"])
        options[option_key].should be_true
      end
    end

    [['-y', :yaml], ['-j', :json]].each do |option, key|
      it "sets options[:#{key}] when given #{option}" do
        options = Facter::Application.parse([option])
        options[key].should be_true
      end
    end

    ['-d', '--debug'].each do |option|
      it "enables debugging when given #{option}" do
        Facter.debugging(false)
        Facter::Application.parse([option])
        Facter.should be_debugging
        Facter.debugging(false)
      end
    end

    ['-t', '--timing'].each do |option|
      it "enables timing when given #{option}" do
        Facter.timing(false)
        Facter::Application.parse([option])
        Facter.should be_timing
        Facter.timing(false)
      end
    end

    ['-p', '--puppet'].each do |option|
      it "calls load_puppet when given #{option}" do
        Facter::Application.expects(:load_puppet)
        Facter::Application.parse([option])
      end
    end

    it 'mutates argv so that non-option arguments are left' do
      argv = ['-y', '--trace', 'uptime', 'virtual']
      Facter::Application.parse(argv)
      argv.should == ['uptime', 'virtual']
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
facter-1.7.6 spec/unit/application_spec.rb
facter-1.7.5 spec/unit/application_spec.rb
facter-1.7.5.rc2 spec/unit/application_spec.rb
facter-1.7.5.rc1 spec/unit/application_spec.rb
facter-1.7.4 spec/unit/application_spec.rb
facter-1.7.4.rc1 spec/unit/application_spec.rb
facter-1.7.3 spec/unit/application_spec.rb
facter-1.7.3.rc1 spec/unit/application_spec.rb
facter-1.7.2 spec/unit/application_spec.rb
facter-1.7.2.rc1 spec/unit/application_spec.rb
facter-1.7.1 spec/unit/application_spec.rb
facter-1.7.1.rc1 spec/unit/application_spec.rb
facter-1.7.0 spec/unit/application_spec.rb
facter-1.7.0.rc2 spec/unit/application_spec.rb
facter-1.7.0.rc1 spec/unit/application_spec.rb
facter-1.6.18 spec/unit/application_spec.rb
facter-1.6.18.rc1 spec/unit/application_spec.rb