I have a simple class that sets the timezone on a Solaris system. I'm 
trying to write tests for it, and failing. It's telling me the file is nil, 
but there should be content as the file does exist. The file is not 
generated via a template or as a static puppet file in the module... the 
module just has an augeas resource to set a shell-style variable inside the 
file:  TZ=<timezone>
 
I have puppetlabs_spec_helper 0.8.1 and rspec-puppet 1.0.1 installed as 
gems into Puppet Enterprise's ruby (PE 3.2.3)
 
Here is the error and the offending rspec code:
 
bsirinek@myhost $ rake spec
/opt/puppet/bin/ruby 
-I/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-support-3.1.0/lib:/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-core-3.1.4/lib
 
/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-core-3.1.4/exe/rspec --pattern 
spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb 
--color
...F
Failures:
  1) timezone when called with parameters on solaris should contain 
Augeas[set_timezone] with incl => "/etc/default/init", lens => 
"Shellvars.lns", changes => "set TZ US/Eastern" and content =~ 
/^TZ=US\/Eastern$/
     Failure/Error: }).with_content(/^TZ=US\/Eastern$/)
       expected that the catalogue would contain Augeas[set_timezone] with 
content set to /^TZ=US\/Eastern$/ but it is set to nil
     # ./spec/classes/timezone_spec.rb:47:in `block (3 levels) in <top 
(required)>'
(...annoying deprecation warnings removed...)
Finished in 0.60314 seconds (files took 1.4 seconds to load)
4 examples, 1 failure
Failed examples:
rspec ./spec/classes/timezone_spec.rb:43 # timezone when called with 
parameters on solaris should contain Augeas[set_timezone] with incl => 
"/etc/default/init", lens => "Shellvars.lns", changes => "set TZ 
US/Eastern" and content =~ /^TZ=US\/Eastern$/
/opt/puppet/bin/ruby 
-I/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-support-3.1.0/lib:/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-core-3.1.4/lib
 
/opt/puppet/lib/ruby/gems/1.9.1/gems/rspec-core-3.1.4/exe/rspec --pattern 
spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb 
--color failed
 
 
rspec test:
 
  describe 'when called with parameter on solaris' do
    let(:facts) { { :osfamily => 'Solaris' } }
    let(:params) { { :time_zone => 'US/Eastern' } }
    it {
      should contain_augeas('set_timezone').with({
        :incl    => '/etc/default/init',
        :lens    => 'Shellvars.lns',
        :changes => "set TZ US/Eastern"
      }).with_content(/^TZ=US\/Eastern$/)
    }
  end
 
The test works fine if I leave off the with_content.
 
Any ideas?
 
Thanks
 
Bill

 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/7007a8e5-df7b-492a-accb-eed09cb12871%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to