diff options
| author | Luke Kanies <luke@madstop.com> | 2008-05-16 10:38:15 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-05-16 10:38:15 -0500 |
| commit | bb41db0bf4221e394411d2a82b6de264b557fb95 (patch) | |
| tree | fbc8773d5e6b5a708db24e3943ca3b3fb7f98880 /spec | |
| parent | 07a3d479b0e31aa7a1f8e6d0e178e440adc57030 (diff) | |
| download | facter-bb41db0bf4221e394411d2a82b6de264b557fb95.tar.gz facter-bb41db0bf4221e394411d2a82b6de264b557fb95.tar.xz facter-bb41db0bf4221e394411d2a82b6de264b557fb95.zip | |
Switching to a search path registration system.
Facter no longer knows anything about Puppet, so there's
no inter-dependency issue.
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/integration/util/loader.rb | 26 | ||||
| -rwxr-xr-x | spec/unit/facter.rb | 25 | ||||
| -rwxr-xr-x | spec/unit/util/loader.rb | 7 |
3 files changed, 32 insertions, 26 deletions
diff --git a/spec/integration/util/loader.rb b/spec/integration/util/loader.rb deleted file mode 100755 index af569cd..0000000 --- a/spec/integration/util/loader.rb +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../spec_helper' - -require 'facter/util/loader' - -begin - require 'puppet' -rescue LoadError - # Oh well, no Puppet :/ -end - -describe Facter::Util::Loader do - if defined?(Puppet) - describe "when the Puppet libraries are loaded" do - before { @loader = Facter::Util::Loader.new } - it "should include the factdest setting" do - @loader.search_path.should be_include(Puppet.settings.value(:factdest)) - end - - it "should include the facter subdirectory of the libdir setting" do - @loader.search_path.should be_include(File.join(Puppet.settings.value(:libdir), "facter")) - end - end - end -end diff --git a/spec/unit/facter.rb b/spec/unit/facter.rb index 59d10d4..18611aa 100755 --- a/spec/unit/facter.rb +++ b/spec/unit/facter.rb @@ -107,6 +107,31 @@ describe Facter do Facter.value(:macaddress).should_not be_include(" ") end + it "should have a method for registering directories to search" do + Facter.should respond_to(:search) + end + + it "should have a method for returning the registered search directories" do + Facter.should respond_to(:search_path) + end + + describe "when registering directories to search" do + after { Facter.instance_variable_set("@search_path", []) } + + it "should allow registration of a directory" do + Facter.search "/my/dir" + end + + it "should allow registration of multiple directories" do + Facter.search "/my/dir", "/other/dir" + end + + it "should return all registered directories when asked" do + Facter.search "/my/dir", "/other/dir" + Facter.search_path.should == %w{/my/dir /other/dir} + end + end + def test_onetrueconfine assert_nothing_raised { Facter.add("required") { diff --git a/spec/unit/util/loader.rb b/spec/unit/util/loader.rb index 5e25ef5..b9b4306 100755 --- a/spec/unit/util/loader.rb +++ b/spec/unit/util/loader.rb @@ -51,6 +51,13 @@ describe Facter::Util::Loader do end end + it "should include all search paths registered with Facter" do + Facter.expects(:search_path).returns %w{/one /two} + paths = @loader.search_path + paths.should be_include("/one") + paths.should be_include("/two") + end + describe "and the FACTERLIB environment variable is set" do it "should include all paths in FACTERLIB" do with_env "FACTERLIB" => "/one/path:/two/path" do |
