using let(:pre_condition) resulting in NoMethodError: I have the following in a Puppet manifest file
I have the following in a manifest file:
@file{
"/usr/var/some_path" :
require => Package['some_package_name'],
path => "an/absolute/path/is/specified/here",
mode => 0644,
ensure => present,
owner => "root",
group => "root",
source => "an/absolute/path/is/specified/here",
notify => Service['service_name_specified'],
}
I've written this in a Ruby spec file:
let(:pre_condition) do
realize( File["an/absolute/path/is/specified/here"] )
When I compile with 'rspec spec' an error messages is being displayed which includes:
Failures:
1) logcollector general validation should contain Package[nwlogcollector] with ensure => "installed"
Failure/Error: realize( File["/usr/lib/collectd/python/comp_modules/cs_logcollector.py"] )
NoMethodError:
undefined method `[]' for File:Class
# ./spec/classes/logcollector_spec.rb:184:in `block (3 levels) in <top (required)>'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.2.0/lib/rspec-puppet/support.rb:90:in `pre_cond'
/Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/formatters/base_text_formatter.rb:46:in `write': Broken pipe - <STDOUT> (Errno::EPIPE)
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/formatters/base_text_formatter.rb:46:in `puts'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/formatters/base_text_formatter.rb:46:in `dump_summary'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/reporter.rb:134:in `block in notify'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/reporter.rb:133:in `each'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/reporter.rb:133:in `notify'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/reporter.rb:116:in `finish'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/reporter.rb:55:in `report'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/runner.rb:107:in `run_specs'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/runner.rb:85:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/runner.rb:69:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/lib/rspec/core/runner.rb:37:in `invoke'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.6/exe/rspec:4:in `<top (required)>'
from /usr/bin/rspec:23:in `load'
from /usr/bin/rspec:23:in `<main>'