Ask Your Question
0

using let(:pre_condition) resulting in NoMethodError: I have the following in a Puppet manifest file

asked 2016-01-22 07:48:57 -0500

pla gravatar image

updated 2016-01-24 02:46:56 -0500

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>'
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-01-24 02:49:08 -0500

updated 2016-01-24 02:52:34 -0500

See here also here.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-01-22 07:48:57 -0500

Seen: 446 times

Last updated: Jan 24 '16