summaryrefslogtreecommitdiff
path: root/chef
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2012-12-14 23:10:10 -0800
committerSteven Danna <steve@opscode.com>2013-01-23 22:37:36 -0800
commitf1d741c2767d5b9298e80027ddc477f176032b27 (patch)
treedce9fe5c6cf1bbb5d2c1597f489092d4ca974c51 /chef
parent786540e0b6754ebd1469142f678d598c64f7ebba (diff)
downloadchef-f1d741c2767d5b9298e80027ddc477f176032b27.tar.gz
[CHEF-3068] Add tests for Chef::Resource#defined_at
Diffstat (limited to 'chef')
-rw-r--r--chef/spec/unit/resource_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/chef/spec/unit/resource_spec.rb b/chef/spec/unit/resource_spec.rb
index a3bed5fce2..e8e364c459 100644
--- a/chef/spec/unit/resource_spec.rb
+++ b/chef/spec/unit/resource_spec.rb
@@ -273,6 +273,29 @@ describe Chef::Resource do
end
end
+ describe "defined_at" do
+ it "should correctly parse source_line on unix-like operating systems" do
+ @resource.source_line = "/some/path/to/file.rb:80:in `wombat_tears'"
+ @resource.defined_at.should == "/some/path/to/file.rb line 80"
+ end
+
+ it "should correctly parse source_line on Windows" do
+ @resource.source_line = "C:/some/path/to/file.rb:80 in 1`wombat_tears'"
+ @resource.defined_at.should == "C:/some/path/to/file.rb line 80"
+ end
+
+ it "should include the cookbook and recipe when it knows it" do
+ @resource.source_line = "/some/path/to/file.rb:80:in `wombat_tears'"
+ @resource.recipe_name = "wombats"
+ @resource.cookbook_name = "animals"
+ @resource.defined_at.should == "animals::wombats line 80"
+ end
+
+ it "should recognize dynamically defined resources" do
+ @resource.defined_at.should == "dynamically defined"
+ end
+ end
+
describe "to_s" do
it "should become a string like resource_name[name]" do
zm = Chef::Resource::ZenMaster.new("coffee")