Ask Your Question
0

rspec-puppet parser error

asked 2015-06-01 13:38:21 -0500

Chutki gravatar image

Hi,

I am doing rsepc-puppet testing but getting below error

(in /etc/puppetlabs/puppet/modules/test)
/usr/bin/ruby -S rspec spec/defines/filetest_spec.rb
F

Failures:

  1) test::filetest
     Failure/Error: it { should contain_class('test_file')}
     Puppet::Error:
       Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type test::filetest at line 4 on node puppet.example.com
     # ./spec/defines/filetest_spec.rb:6

Finished in 0.05463 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/defines/filetest_spec.rb:6 # test::filetest
rake aborted!
ruby -S rspec spec/defines/filetest_spec.rb failed

below is my tree

.
|-- manifests
|   `-- test_file.pp
|-- Rakefile
`-- spec
    |-- classes
    |-- defines
    |   `-- filetest_spec.rb
    |-- fixtures
    |   |-- manifests
    |   |   `-- site.pp
    |   `-- modules
    |       `-- test
    |           |-- files -> ../../../../files
    |           |-- lib -> ../../../../lib
    |           |-- manifests -> ../../../../manifests
    |           `-- templates -> ../../../../templates
    |-- functions
    |-- hosts
    `-- spec_helper.rb

my test_file.pp

class test_file {
  notify { 'hi':}
}

include test_file

below is spec/defines/filetest_spec.rb

require 'spec_helper'

describe 'test::filetest' do
  let(:title) { 'testrspec' }

  it { should contain_class('test_file')}
end

gem list

rake (0.8.7)
rspec (1.3.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-puppet (1.0.1)

why I am getting this error, did I do any blunder

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-06-01 15:02:35 -0500

Hi Chutki

I think you should just put your class name into your describe section, remove the title (as it is not a defined type), and move the spec file to the classes directory:

describe 'test_file' do
  it { should contain_class('test_file')}
end

it seems that you mix both :)

hope this can help!!

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: 2015-06-01 13:38:21 -0500

Seen: 100 times

Last updated: Jun 01 '15