diff options
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/resource/catalog_spec.rb | 9 | ||||
| -rwxr-xr-x | spec/unit/type/file_spec.rb | 14 | ||||
| -rwxr-xr-x | spec/unit/type_spec.rb | 21 |
3 files changed, 44 insertions, 0 deletions
diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb index b6f96f094..10cff91a3 100755 --- a/spec/unit/resource/catalog_spec.rb +++ b/spec/unit/resource/catalog_spec.rb @@ -1066,4 +1066,13 @@ describe Puppet::Resource::Catalog, "when converting from pson" do lambda { PSON.parse @pson.to_pson }.should raise_error(ArgumentError) end + + describe "#title_key_for_ref" do + it "should parse a resource ref string into a pair" do + @catalog.title_key_for_ref("Title[name]").should == ["Title", "name"] + end + it "should parse a resource ref string into a pair, even if there's a newline inside the name" do + @catalog.title_key_for_ref("Title[na\nme]").should == ["Title", "na\nme"] + end + end end diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 845bf3d8b..7d93dfd64 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -1053,4 +1053,18 @@ describe Puppet::Type.type(:file) do file.retrieve end end + + describe ".title_patterns" do + before do + @type_class = Puppet::Type.type(:file) + end + + it "should have a regexp that captures the entire string, except for a terminating slash" do + patterns = @type_class.title_patterns + string = "abc/\n\tdef/" + patterns[0][0] =~ string + $1.should == "abc/\n\tdef" + end + end + end diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb index 683529d8a..71d415dc6 100755 --- a/spec/unit/type_spec.rb +++ b/spec/unit/type_spec.rb @@ -406,6 +406,27 @@ describe Puppet::Type do end end + describe ".title_patterns" do + describe "when there's one namevar" do + before do + @type_class = Puppet::Type.type(:notify) + @type_class.stubs(:key_attributes).returns([:one]) + end + + it "should have a default pattern for when there's one namevar" do + patterns = @type_class.title_patterns + patterns.length.should == 1 + patterns[0].length.should == 2 + end + + it "should have a regexp that captures the entire string" do + patterns = @type_class.title_patterns + string = "abc\n\tdef" + patterns[0][0] =~ string + $1.should == "abc\n\tdef" + end + end + end describe "when in a catalog" do before do |
