Sha256: de0d58da59a57ef2e9c3d58aff23d844c8b5706c98a7b19f77532bc5891d463f

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

#!/usr/bin/env ruby
#
#  Created by Luke Kanies on 2008-4-8.
#  Copyright (c) 2008. All rights reserved.

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

describe Puppet::Node::Facts do
    describe "when using the indirector" do
        after { Puppet::Util::Cacher.expire }

        it "should expire any cached node instances when it is saved" do
            Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml

            Puppet::Node::Facts.indirection.terminus(:yaml).should equal(Puppet::Node::Facts.indirection.terminus(:yaml))
            terminus = Puppet::Node::Facts.indirection.terminus(:yaml)
            terminus.stubs :save

            Puppet::Node.expects(:expire).with("me")

            facts = Puppet::Node::Facts.new("me")
            facts.save
        end

        it "should be able to delegate to the :yaml terminus" do
            Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml

            # Load now, before we stub the exists? method.
            terminus = Puppet::Node::Facts.indirection.terminus(:yaml)

            terminus.expects(:path).with("me").returns "/my/yaml/file"
            FileTest.expects(:exist?).with("/my/yaml/file").returns false

            Puppet::Node::Facts.find("me").should be_nil
        end

        it "should be able to delegate to the :facter terminus" do
            Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :facter

            Facter.expects(:to_hash).returns "facter_hash"
            facts = Puppet::Node::Facts.new("me")
            Puppet::Node::Facts.expects(:new).with("me", "facter_hash").returns facts

            Puppet::Node::Facts.find("me").should equal(facts)
        end
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-0.25.5 spec/integration/node/facts.rb
puppet-0.25.4 spec/integration/node/facts.rb
puppet-0.25.3 spec/integration/node/facts.rb
puppet-0.25.2 spec/integration/node/facts.rb
puppet-0.25.1 spec/integration/node/facts.rb
puppet-0.25.0 spec/integration/node/facts.rb