Sha256: 34577aad30a5b786cb066fc9e684ed98a3172d8b815a4c10f3cadafde26e12d8

Contents?: true

Size: 1.88 KB

Versions: 4

Compression:

Stored size: 1.88 KB

Contents

#! /usr/bin/env ruby -S rspec
require 'spec_helper'

require 'puppet/application/describe'

describe Puppet::Application::Describe do
  before :each do
    @describe = Puppet::Application[:describe]
  end

  it "should declare a main command" do
    @describe.should respond_to(:main)
  end

  it "should declare a preinit block" do
    @describe.should respond_to(:preinit)
  end

  [:providers,:list,:meta].each do |option|
    it "should declare handle_#{option} method" do
      @describe.should respond_to("handle_#{option}".to_sym)
    end

    it "should store argument value when calling handle_#{option}" do
      @describe.options.expects(:[]=).with("#{option}".to_sym, 'arg')
      @describe.send("handle_#{option}".to_sym, 'arg')
    end
  end


  describe "in preinit" do
    it "should set options[:parameteers] to true" do
      @describe.preinit

      @describe.options[:parameters].should be_true
    end
  end

  describe "when handling parameters" do
    it "should set options[:parameters] to false" do
      @describe.handle_short(nil)

      @describe.options[:parameters].should be_false
    end
  end

  describe "during setup" do
    it "should collect arguments in options[:types]" do
      @describe.command_line.stubs(:args).returns(['1','2'])
      @describe.setup

      @describe.options[:types].should == ['1','2']
    end
  end

  describe "when running" do

    before :each do
      @typedoc = stub 'type_doc'
      TypeDoc.stubs(:new).returns(@typedoc)
    end

    it "should call list_types if options list is set" do
      @describe.options[:list] = true

      @typedoc.expects(:list_types)

      @describe.run_command
    end

    it "should call format_type for each given types" do
      @describe.options[:list] = false
      @describe.options[:types] = ['type']

      @typedoc.expects(:format_type).with('type', @describe.options)
      @describe.run_command
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 spec/unit/application/describe_spec.rb
puppet-3.0.0.rc7 spec/unit/application/describe_spec.rb
puppet-3.0.0.rc5 spec/unit/application/describe_spec.rb
puppet-3.0.0.rc4 spec/unit/application/describe_spec.rb