25
25
@original_required.each {|f| $".push f unless $".include? f }
28
describe "::prefix_match?" do
30
{ ['1.0.0', '1.0.0'] => true,
31
['1.0', '1.0.0'] => true,
32
['1', '1.0.0'] => true,
33
['1.0.0', '1.1.0'] => false,
34
['1.0', '1.1.0'] => false,
35
['1', '1.1.0'] => true,
36
['1.0.1', '1.0.0'] => false,
37
}.each do |data, result|
38
it "should return #{result.inspect} for prefix_match?(#{data.join(', ')})" do
39
subject.prefix_match?(*data).should == result
44
describe "::validate_version" do
47
'10.10.10beta' => true,
51
}.each do |input, result|
52
it "should#{result ? '' : ' not'} permit #{input.inspect}" do
53
subject.validate_version(input).should(result ? be_true : be_false)
60
subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10
30
subject.instance_variable_get("@faces")[:foo][SemVer.new('0.0.1')] = 10
63
33
it "should return the face with the given name" do
67
37
it "should attempt to load the face if it isn't found" do
68
subject.expects(:require).with('puppet/face/bar')
38
subject.expects(:require).once.with('puppet/face/bar')
39
subject.expects(:require).once.with('puppet/face/0.0.1/bar')
69
40
subject["bar", '0.0.1']
77
48
it "should return true if the face specified is registered" do
78
subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10
49
subject.instance_variable_get("@faces")[:foo][SemVer.new('0.0.1')] = 10
79
50
subject["foo", '0.0.1'].should == 10
82
53
it "should attempt to require the face if it is not registered" do
83
54
subject.expects(:require).with do |file|
84
subject.instance_variable_get("@faces")[:bar]['0.0.1'] = true
55
subject.instance_variable_get("@faces")[:bar][SemVer.new('0.0.1')] = true
85
56
file == 'puppet/face/bar'
87
58
subject["bar", '0.0.1'].should be_true
95
66
it "should return false if the face file itself is missing" do
96
67
subject.stubs(:require).
97
raises(LoadError, 'no such file to load -- puppet/face/bar')
68
raises(LoadError, 'no such file to load -- puppet/face/bar').then.
69
raises(LoadError, 'no such file to load -- puppet/face/0.0.1/bar')
98
70
subject["bar", '0.0.1'].should be_false
102
describe "::get_action_for_face" do
103
it "should return an action on the current face" do
104
Puppet::Face::FaceCollection.get_action_for_face(:huzzah, :bar, :current).
105
should be_an_instance_of Puppet::Interface::Action
108
it "should return an action on an older version of a face" do
109
action = Puppet::Face::FaceCollection.
110
get_action_for_face(:huzzah, :obsolete, :current)
112
action.should be_an_instance_of Puppet::Interface::Action
113
action.face.version.should == SemVer.new('1.0.0')
116
it "should load the full older version of a face" do
117
action = Puppet::Face::FaceCollection.
118
get_action_for_face(:huzzah, :obsolete, :current)
120
action.face.version.should == SemVer.new('1.0.0')
121
action.face.should be_action :obsolete_in_core
124
it "should not add obsolete actions to the current version" do
125
action = Puppet::Face::FaceCollection.
126
get_action_for_face(:huzzah, :obsolete, :current)
128
action.face.version.should == SemVer.new('1.0.0')
129
action.face.should be_action :obsolete_in_core
131
current = Puppet::Face[:huzzah, :current]
132
current.version.should == SemVer.new('2.0.1')
133
current.should_not be_action :obsolete_in_core
134
current.should_not be_action :obsolete
130
138
describe "::register" do
131
139
it "should store the face by name" do
132
140
face = Puppet::Face.new(:my_face, '0.0.1')
133
141
subject.register(face)
134
subject.instance_variable_get("@faces").should == {:my_face => {'0.0.1' => face}}
142
subject.instance_variable_get("@faces").should == {
143
:my_face => { face.version => face }