summaryrefslogtreecommitdiff
path: root/chef/spec/unit/provider/template_spec.rb
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2012-07-24 13:45:39 -0400
committerBryan McLellan <btm@loftninjas.org>2012-07-24 13:45:39 -0400
commitc19064fdbebaebbdd20f03b6123978a7c2f1ac74 (patch)
tree21b60c9e51348c288f220a10331e3af5fc9a6881 /chef/spec/unit/provider/template_spec.rb
parent3c923a2c59b66cd8b9ab359e6a27b31d3c9f6fff (diff)
downloadchef-c19064fdbebaebbdd20f03b6123978a7c2f1ac74.tar.gz
Fix template spec on Windows by stubbing out Etc
Using the Etc module to get information about root isn't going to work on Windows, or any platform without uid/gid 0, so we stub it out and return a struct.
Diffstat (limited to 'chef/spec/unit/provider/template_spec.rb')
-rw-r--r--chef/spec/unit/provider/template_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/chef/spec/unit/provider/template_spec.rb b/chef/spec/unit/provider/template_spec.rb
index ac6e5f2b2c..e146669ba2 100644
--- a/chef/spec/unit/provider/template_spec.rb
+++ b/chef/spec/unit/provider/template_spec.rb
@@ -17,6 +17,8 @@
#
require 'stringio'
require 'spec_helper'
+require 'etc'
+require 'ostruct'
describe Chef::Provider::Template do
before(:each) do
@@ -38,6 +40,14 @@ describe Chef::Provider::Template do
@provider.current_resource = @current_resource
@access_controls = mock("access controls")
@provider.stub!(:access_controls).and_return(@access_controls)
+ passwd_struct = if windows?
+ Struct::Passwd.new("root", "x", 0, 0, "/root", "/bin/bash")
+ else
+ Struct::Passwd.new("root", "x", 0, 0, "root", "/root", "/bin/bash")
+ end
+ group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0)
+ Etc.stub!(:getpwuid).and_return(passwd_struct)
+ Etc.stub!(:getgrgid).and_return(group_struct)
end
describe "when creating the template" do