summaryrefslogtreecommitdiffstats
path: root/spec/integration/node.rb
blob: 631d4403e024e4fc8b7df09f11a571bf6d6b9628 (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
39
40
41
42
43
44
#!/usr/bin/env ruby
#
#  Created by Luke Kanies on 2007-9-23.
#  Copyright (c) 2007. All rights reserved.

require File.dirname(__FILE__) + '/../spec_helper'

require 'puppet/node'

describe Puppet::Node, " when using the memory terminus" do
    before do
        @name = "me"
        @old_terminus = Puppet::Node.indirection.terminus_class
        @terminus = Puppet::Node.indirection.terminus(:memory)
        Puppet::Node.indirection.stubs(:terminus).returns @terminus
        @node = Puppet::Node.new(@name)
    end

    it "should find no nodes by default" do
        Puppet::Node.find(@name).should be_nil
    end

    it "should be able to find nodes that were previously saved" do
        @node.save
        Puppet::Node.find(@name).should equal(@node)
    end

    it "should replace existing saved nodes when a new node with the same name is saved" do
        @node.save
        two = Puppet::Node.new(@name)
        two.save
        Puppet::Node.find(@name).should equal(two)
    end

    it "should be able to remove previously saved nodes" do
        @node.save
        Puppet::Node.destroy(@node)
        Puppet::Node.find(@name).should be_nil
    end

    it "should fail when asked to destroy a node that does not exist" do
        proc { Puppet::Node.destroy(@node) }.should raise_error(ArgumentError)
    end
end