summaryrefslogtreecommitdiffstats
path: root/spec/unit/application/indirection_base_spec.rb
blob: 63ab11eed44df80392034b2fa2c57043c99db0dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env rspec
require 'spec_helper'
require 'puppet/application/indirection_base'
require 'puppet/face/indirector'

########################################################################
# Stub for testing; the names are critical, sadly. --daniel 2011-03-30
class Puppet::Application::TestIndirection < Puppet::Application::IndirectionBase
end

face = Puppet::Face::Indirector.define(:testindirection, '0.0.1') do
end
# REVISIT: This horror is required because we don't allow anything to be
# :current except for if it lives on, and is loaded from, disk. --daniel 2011-03-29
face.instance_variable_set('@version', :current)
Puppet::Face.register(face)
########################################################################


describe Puppet::Application::IndirectionBase do
  subject { Puppet::Application::TestIndirection.new }

  it "should accept a terminus command line option" do
    # It would be nice not to have to stub this, but whatever... writing an
    # entire indirection stack would cause us more grief. --daniel 2011-03-31
    terminus = mock("test indirection terminus")
    Puppet::Indirector::Indirection.expects(:instance).
      with(:testindirection).twice.returns()

    subject.command_line.
      instance_variable_set('@args', %w{--terminus foo save})

    # Not a very nice thing. :(
    $stderr.stubs(:puts)

    expect { subject.run }.should raise_error SystemExit
  end
end