~gandelman-a/ubuntu/precise/facter/merge922788

« back to all changes in this revision

Viewing changes to spec/unit/util/fact_spec.rb

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2011-10-18 10:32:42 UTC
  • mfrom: (1.3.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: package-import@ubuntu.com-20111018103242-ag8i8vejfp8v7b1b
Tags: upstream-1.6.1
ImportĀ upstreamĀ versionĀ 1.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
            @fact.add { }
57
57
        end
58
58
 
59
 
        it "should re-sort the resolutions by length, so the most restricted resolutions are first" do
60
 
            r1 = stub 'r1', :length => 1
61
 
            r2 = stub 'r2', :length => 2
62
 
            r3 = stub 'r3', :length => 0
 
59
        it "should re-sort the resolutions by weight, so the most restricted resolutions are first" do
 
60
            r1 = stub 'r1', :weight => 1
 
61
            r2 = stub 'r2', :weight => 2
 
62
            r3 = stub 'r3', :weight => 0
63
63
            Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
64
64
            @fact.add { }
65
65
            @fact.add { }
83
83
        end
84
84
 
85
85
        it "should return the first value returned by a resolution" do
86
 
            r1 = stub 'r1', :length => 2, :value => nil, :suitable? => true
87
 
            r2 = stub 'r2', :length => 1, :value => "yay", :suitable? => true
88
 
            r3 = stub 'r3', :length => 0, :value => "foo", :suitable? => true
 
86
            r1 = stub 'r1', :weight => 2, :value => nil, :suitable? => true
 
87
            r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
 
88
            r3 = stub 'r3', :weight => 0, :value => "foo", :suitable? => true
89
89
            Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3)
90
90
            @fact.add { }
91
91
            @fact.add { }
95
95
        end
96
96
 
97
97
        it "should short-cut returning the value once one is found" do
98
 
            r1 = stub 'r1', :length => 2, :value => "foo", :suitable? => true
99
 
            r2 = stub 'r2', :length => 1, :suitable? => true # would fail if 'value' were asked for
 
98
            r1 = stub 'r1', :weight => 2, :value => "foo", :suitable? => true
 
99
            r2 = stub 'r2', :weight => 1, :suitable? => true # would fail if 'value' were asked for
100
100
            Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
101
101
            @fact.add { }
102
102
            @fact.add { }
105
105
        end
106
106
 
107
107
        it "should skip unsuitable resolutions" do
108
 
            r1 = stub 'r1', :length => 2, :suitable? => false # would fail if 'value' were asked for'
109
 
            r2 = stub 'r2', :length => 1, :value => "yay", :suitable? => true
 
108
            r1 = stub 'r1', :weight => 2, :suitable? => false # would fail if 'value' were asked for'
 
109
            r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true
110
110
            Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2)
111
111
            @fact.add { }
112
112
            @fact.add { }