Sha256: 8c3dd3d40a517c2db30d5977ec3a907a67fe321bf33dcf473cfaa28aee665864

Contents?: true

Size: 1.9 KB

Versions: 150

Compression:

Stored size: 1.9 KB

Contents

#! /usr/bin/env ruby
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
    expect(@describe).to respond_to(:main)
  end

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

  [:providers,:list,:meta].each do |option|
    it "should declare handle_#{option} method" do
      expect(@describe).to 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[:parameters] to true" do
      @describe.preinit

      expect(@describe.options[:parameters]).to be_truthy
    end
  end

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

      expect(@describe.options[:parameters]).to be_falsey
    end
  end

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

      expect(@describe.options[:types]).to eq(['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

150 entries across 150 versions & 1 rubygems

Version Path
puppet-4.10.12 spec/unit/application/describe_spec.rb
puppet-4.10.12-x86-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.12-x64-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.12-universal-darwin spec/unit/application/describe_spec.rb
puppet-4.10.11 spec/unit/application/describe_spec.rb
puppet-4.10.11-x86-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.11-x64-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.11-universal-darwin spec/unit/application/describe_spec.rb
puppet-4.10.10 spec/unit/application/describe_spec.rb
puppet-4.10.10-x86-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.10-x64-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.10-universal-darwin spec/unit/application/describe_spec.rb
puppet-4.10.9 spec/unit/application/describe_spec.rb
puppet-4.10.9-x86-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.9-x64-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.9-universal-darwin spec/unit/application/describe_spec.rb
puppet-4.10.8 spec/unit/application/describe_spec.rb
puppet-4.10.8-x86-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.8-x64-mingw32 spec/unit/application/describe_spec.rb
puppet-4.10.8-universal-darwin spec/unit/application/describe_spec.rb