210
210
expect { @apply.main }.to exit_with 0
213
it "should set the facts name based on the node_name_fact" do
214
@facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
215
Puppet::Node::Facts.indirection.save(@facts)
217
node = Puppet::Node.new('other_node_name')
218
Puppet::Node.indirection.save(node)
220
Puppet[:node_name_fact] = 'my_name_fact'
222
expect { @apply.main }.to exit_with 0
224
@facts.name.should == 'other_node_name'
227
it "should set the node_name_value based on the node_name_fact" do
228
facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
229
Puppet::Node::Facts.indirection.save(facts)
230
node = Puppet::Node.new('other_node_name')
231
Puppet::Node.indirection.save(node)
232
Puppet[:node_name_fact] = 'my_name_fact'
234
expect { @apply.main }.to exit_with 0
236
Puppet[:node_name_value].should == 'other_node_name'
239
it "should raise an error if we can't find the facts" do
240
Puppet::Node::Facts.indirection.expects(:find).returns(nil)
242
lambda { @apply.main }.should raise_error
245
213
it "should raise an error if we can't find the node" do
246
214
Puppet::Node.indirection.expects(:find).returns(nil)
248
216
lambda { @apply.main }.should raise_error
251
it "should merge in our node the loaded facts" do
252
@facts.values = {'key' => 'value'}
254
expect { @apply.main }.to exit_with 0
256
@node.parameters['key'].should == 'value'
259
219
it "should load custom classes if loadclasses" do
260
220
@apply.options[:loadclasses] = true
261
221
classfile = tmpfile('classfile')
308
268
expect { @apply.main }.to exit_with 0
271
describe "when using node_name_fact" do
273
@facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
274
Puppet::Node::Facts.indirection.save(@facts)
275
@node = Puppet::Node.new('other_node_name')
276
Puppet::Node.indirection.save(@node)
277
Puppet[:node_name_fact] = 'my_name_fact'
280
it "should set the facts name based on the node_name_fact" do
281
expect { @apply.main }.to exit_with 0
282
@facts.name.should == 'other_node_name'
285
it "should set the node_name_value based on the node_name_fact" do
286
expect { @apply.main }.to exit_with 0
287
Puppet[:node_name_value].should == 'other_node_name'
290
it "should merge in our node the loaded facts" do
291
@facts.values.merge!('key' => 'value')
293
expect { @apply.main }.to exit_with 0
295
@node.parameters['key'].should == 'value'
298
it "should raise an error if we can't find the facts" do
299
Puppet::Node::Facts.indirection.expects(:find).returns(nil)
301
lambda { @apply.main }.should raise_error
311
305
describe "with detailed_exitcodes" do
313
307
@apply.options[:detailed_exitcodes] = true