summaryrefslogtreecommitdiffstats
path: root/spec/unit/string/string_collection_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/string/string_collection_spec.rb')
-rwxr-xr-xspec/unit/string/string_collection_spec.rb54
1 files changed, 23 insertions, 31 deletions
diff --git a/spec/unit/string/string_collection_spec.rb b/spec/unit/string/string_collection_spec.rb
index fa63f18e3..fab647da0 100755
--- a/spec/unit/string/string_collection_spec.rb
+++ b/spec/unit/string/string_collection_spec.rb
@@ -70,7 +70,6 @@ describe Puppet::String::StringCollection do
it "should attempt to load the string if it isn't found" do
subject.expects(:require).with('puppet/string/bar')
- subject.expects(:require).with('bar@0.0.1/puppet/string/bar')
subject["bar", '0.0.1']
end
@@ -104,26 +103,15 @@ describe Puppet::String::StringCollection do
end
end
- it "should require the string by version if the 'current' version isn't it" do
- subject.expects(:require).with('puppet/string/bar').
- raises(LoadError, 'no such file to load -- puppet/string/bar')
- subject.expects(:require).with do |file|
- subject.instance_variable_get("@strings")[:bar]['0.0.1'] = true
- file == 'bar@0.0.1/puppet/string/bar'
- end
- subject.string?("bar", '0.0.1').should == true
- end
-
it "should return false if the string is not registered" do
subject.stubs(:require).returns(true)
- subject.string?("bar", '0.0.1').should == false
+ subject.string?("bar", '0.0.1').should be_false
end
- it "should return false if there is a LoadError requiring the string" do
+ it "should return false if the string file itself is missing" do
subject.stubs(:require).
- raises(LoadError, 'no such file to load -- puppet/string/bar').then.
- raises(LoadError, 'no such file to load -- bar@0.0.1/puppet/string/bar')
- subject.string?("bar", '0.0.1').should == false
+ raises(LoadError, 'no such file to load -- puppet/string/bar')
+ subject.string?("bar", '0.0.1').should be_false
end
it "should register the version loaded by `:current` as `:current`" do
@@ -135,24 +123,28 @@ describe Puppet::String::StringCollection do
subject.instance_variable_get("@strings")[:huzzah][:current].should == :huzzah_string
end
- it "should register the version loaded from `puppet/string/{name}` as `:current`" do
- subject.expects(:require).with do |file|
- subject.instance_variable_get("@strings")[:huzzah]['2.0.1'] = :huzzah_string
- file == 'puppet/string/huzzah'
+ context "with something on disk" do
+ before :each do
+ write_scratch_string :huzzah do |fh|
+ fh.puts <<EOF
+Puppet::String.define(:huzzah, '2.0.1') do
+ action :bar do "is where beer comes from" end
+end
+EOF
+ end
end
- subject.string?("huzzah", '2.0.1')
- subject.instance_variable_get("@strings")[:huzzah][:current].should == :huzzah_string
- end
- it "should not register the version loaded from `{name}@{version}` as `:current`" do
- subject.expects(:require).with('puppet/string/huzzah').
- raises(LoadError, 'no such file to load -- puppet/string/huzzah')
- subject.expects(:require).with do |file|
- subject.instance_variable_get("@strings")[:huzzah]['0.0.1'] = true
- file == 'huzzah@0.0.1/puppet/string/huzzah'
+ it "should register the version loaded from `puppet/string/{name}` as `:current`" do
+ subject.should be_string "huzzah", '2.0.1'
+ subject.should be_string "huzzah", :current
+ Puppet::String[:huzzah, '2.0.1'].should == Puppet::String[:huzzah, :current]
+ end
+
+ it "should index :current when the code was pre-required" do
+ subject.instance_variable_get("@strings")[:huzzah].should_not be_key :current
+ require 'puppet/string/huzzah'
+ subject.string?(:huzzah, :current).should be_true
end
- subject.string?("huzzah", '0.0.1')
- subject.instance_variable_get("@strings")[:huzzah].should_not have_key(:current)
end
end