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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
require 'puppet/application/interface_base'
describe Puppet::Application::InterfaceBase do
before :all do
@dir = Dir.mktmpdir
$LOAD_PATH.push(@dir)
FileUtils.mkdir_p(File.join @dir, 'puppet', 'interface', 'v0.0.1')
FileUtils.touch(File.join @dir, 'puppet', 'interface', 'v0.0.1', 'basetest.rb')
end
after :all do
FileUtils.remove_entry_secure @dir
$LOAD_PATH.pop
end
base_interface = Puppet::Interface.define(:basetest, '0.0.1')
class Puppet::Application::InterfaceBase::Basetest < Puppet::Application::InterfaceBase
end
before do
@app = Puppet::Application::InterfaceBase::Basetest.new
@app.stubs(:interface).returns base_interface
@app.stubs(:exit)
@app.stubs(:puts)
Puppet::Util::Log.stubs(:newdestination)
end
describe "when calling main" do
before do
@app.verb = :find
@app.arguments = ["myname", "myarg"]
@app.interface.stubs(:find)
end
it "should send the specified verb and name to the interface" do
@app.interface.expects(:find).with("myname", "myarg")
@app.main
end
it "should use its render method to render any result"
it "should exit with the current exit code"
end
describe "during setup" do
before do
@app.command_line.stubs(:args).returns(["find", "myname", "myarg"])
@app.stubs(:validate)
end
it "should set the verb from the command line arguments" do
@app.setup
@app.verb.should == "find"
end
it "should make sure arguments are an array" do
@app.command_line.stubs(:args).returns(["find", "myname", "myarg"])
@app.setup
@app.arguments.should == ["myname", "myarg"]
end
it "should set the options on the interface" do
@app.options[:foo] = "bar"
@app.setup
@app.interface.options.should == @app.options
end
end
end
|