Sha256: 56b43b60d1ee0da0080cf09e42e4cbab06f21cca358bf717a9035a64e1795444

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 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::Node::Facts.indirection.clear_cache }

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

            terminus.expects(: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

3 entries across 3 versions & 1 rubygems

Version Path
puppet-0.24.9 spec/integration/node/facts.rb
puppet-0.24.7 spec/integration/node/facts.rb
puppet-0.24.8 spec/integration/node/facts.rb