[Pkg-puppet-devel] [facter] 245/352: (maint) Clean up facter specs

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 71f1d66906c9fc0ea6261416a63770dcc022580e
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Mon Feb 3 14:54:23 2014 -0800

    (maint) Clean up facter specs
    
    This reorganizes tests against the top level collection, deletes some
    tests that have absolutely nothing to do with the Facter object, and
    removes tests that check for a method since other tests will fail if
    those methods are removed.
---
 spec/unit/facter_spec.rb | 138 ++++++++++++++++-------------------------------
 1 file changed, 47 insertions(+), 91 deletions(-)

diff --git a/spec/unit/facter_spec.rb b/spec/unit/facter_spec.rb
index 1b87ef3..9cf03f8 100755
--- a/spec/unit/facter_spec.rb
+++ b/spec/unit/facter_spec.rb
@@ -3,62 +3,60 @@
 require 'spec_helper'
 
 describe Facter do
-  it "should have a method for returning its collection" do
-    Facter.should respond_to(:collection)
-  end
-
-  it "should cache the collection" do
+  it "caches the collection" do
     Facter.collection.should equal(Facter.collection)
   end
 
-  it "should delegate the :flush method to the collection" do
-    Facter.collection.expects(:flush)
-    Facter.flush
-  end
+  describe "methods on the collection" do
+    it "delegates the :flush method to the collection" do
+      Facter.collection.expects(:flush)
+      Facter.flush
+    end
 
-  it "should delegate the :fact method to the collection" do
-    Facter.collection.expects(:fact).with("afact")
-    Facter.fact("afact")
-  end
+    it "delegates the :fact method to the collection" do
+      Facter.collection.expects(:fact).with("afact")
+      Facter.fact("afact")
+    end
 
-  it "should delegate the :list method to the collection" do
-    Facter.collection.expects(:list)
-    Facter.list
-  end
+    it "delegates the :list method to the collection" do
+      Facter.collection.expects(:list)
+      Facter.list
+    end
 
-  it "should load all facts when listing" do
-    Facter.collection.expects(:load_all)
-    Facter.list
-  end
+    it "loads all facts when listing" do
+      Facter.collection.expects(:load_all)
+      Facter.list
+    end
 
-  it "should delegate the :to_hash method to the collection" do
-    Facter.collection.expects(:to_hash)
-    Facter.to_hash
-  end
+    it "delegates the :to_hash method to the collection" do
+      Facter.collection.expects(:to_hash)
+      Facter.to_hash
+    end
 
-  it "should load all facts when calling :to_hash" do
-    Facter.collection.expects(:load_all)
-    Facter.collection.stubs(:to_hash)
-    Facter.to_hash
-  end
+    it "loads all facts when calling :to_hash" do
+      Facter.collection.expects(:load_all)
+      Facter.collection.stubs(:to_hash)
+      Facter.to_hash
+    end
 
-  it "should delegate the :value method to the collection" do
-    Facter.collection.expects(:value).with("myvaluefact")
-    Facter.value("myvaluefact")
-  end
+    it "delegates the :value method to the collection" do
+      Facter.collection.expects(:value).with("myvaluefact")
+      Facter.value("myvaluefact")
+    end
 
-  it "should delegate the :each method to the collection" do
-    Facter.collection.expects(:each)
-    Facter.each
-  end
+    it "delegates the :each method to the collection" do
+      Facter.collection.expects(:each)
+      Facter.each
+    end
 
-  it "should load all facts when calling :each" do
-    Facter.collection.expects(:load_all)
-    Facter.collection.stubs(:each)
-    Facter.each
+    it "loads all facts when calling :each" do
+      Facter.collection.expects(:load_all)
+      Facter.collection.stubs(:each)
+      Facter.each
+    end
   end
 
-  it "should yield to the block when using :each" do
+  it "yields to the block when using :each" do
     Facter.collection.stubs(:load_all)
     Facter.collection.stubs(:each).yields "foo"
     result = []
@@ -66,75 +64,33 @@ describe Facter do
     result.should == %w{foo}
   end
 
-  describe "when provided code as a string" do
-    it "should execute the code in the shell" do
-      test_command = Facter::Util::Config.is_windows? ? 'cmd.exe /c echo yup' : 'echo yup'
-      Facter.add("shell_testing") do
-        setcode test_command
-      end
-
-      Facter["shell_testing"].value.should == "yup"
-    end
-  end
-
-  describe "when passed code as a block" do
-    it "should execute the provided block" do
-      Facter.add("block_testing") { setcode { "foo" } }
-
-      Facter["block_testing"].value.should == "foo"
-    end
-  end
-
-  # #33 Make sure we only get one mac address
-  it "should only return one mac address" do
-    if macaddress = Facter.value(:macaddress)
-      macaddress.should_not be_include(" ")
-    end
-  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
-
-  it "should have a method for registering directories to search for external facts" do
-    Facter.should respond_to(:search_external)
-  end
-
-  it "should have a method for returning the registered search directories for external facts" do
-    Facter.should respond_to(:search_external_path)
-  end
-
   describe "when registering directories to search" do
     after { Facter.reset_search_path! }
 
-    it "should allow registration of a directory" do
+    it "allows registration of a directory" do
       Facter.search "/my/dir"
     end
 
-    it "should allow registration of multiple directories" do
+    it "allows registration of multiple directories" do
       Facter.search "/my/dir", "/other/dir"
     end
 
-    it "should return all registered directories when asked" do
+    it "returns all registered directories when asked" do
       Facter.search "/my/dir", "/other/dir"
       Facter.search_path.should == %w{/my/dir /other/dir}
     end
   end
 
   describe "when registering directories to search for external facts" do
-    it "should allow registration of a directory" do
+    it "allows registration of a directory" do
       Facter.search_external ["/my/dir"]
     end
 
-    it "should allow registration of multiple directories" do
+    it "allows registration of multiple directories" do
       Facter.search_external ["/my/dir", "/other/dir"]
     end
 
-    it "should return all registered directories when asked" do
+    it "returns all registered directories when asked" do
       Facter.search_external ["/my/dir", "/other/dir"]
       Facter.search_external_path.should include("/my/dir", "/other/dir")
     end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list