Ask Your Question

rspec-puppet does not support file_line resource

asked 2015-07-23 06:44:02 -0600

Chutki gravatar image


I have below manifests with file_line resource

class login {

  if $::operatingsystemmajrelease < 7 {

    file {'/etc/loginfile':
      ensure => present,

    file_line { 'testfile':
      path   => '/etc/loginfile',
      line   => 'abc 022',
      match  => '^abc.*$',

Below is rspec file

require 'spec_helper'

describe 'login' do

  it { should contain_class('login')}

  let(:facts) {{:operatingsystemmajrelease => 6}}

  if (6 < 7)
    it { should contain_file('/etc/loginfile').with_ensure('present')}

    it { should contain_file_line('testfile').with(
      :path   => '/etc/loginfile',
      :line   => 'abc 022',
      :match  => '^abc.*$'

When I run rake-spec command getting below error

     Failure/Error: it { should contain_class('login')}
       Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type file_line at /etc/puppetlabs/modulename/login/spec/fixtures/modules/login_defs/manifests/init.pp:17 on node 
     # ./spec/classes/login_spec.rb:5
rspec will not support file_line resporce?

Becase if I remove "file_line" resource and run rsepc file its working

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-07-23 11:15:10 -0600

GregLarkin gravatar image

updated 2015-07-31 01:03:57 -0600

It sounds like you need to set up a fixtures file to pull in your module dependencies:

UPDATE: Now that you have set up your .fixtures.yml file, make sure that you have git installed on your machine. If you don't, the "git clone" operation will fail.

edit flag offensive delete link more


Already file directory was linked to fixtures file "lrwxrwxrwx 1 root root 17 Jul 17 08:38 files -> ../../../../files" under spec/fixtures/modules/modulename

Chutki gravatar imageChutki ( 2015-07-24 07:13:14 -0600 )edit

Did you follow this instruction? "puppetlabs_spec_helper has the ability to populate the spec/fixtures/modules directory with dependent modules when rake spec or rake spec_prep is run. To do so, all required modules should be listed in a file named .fixtures.yml in the root of the project."

GregLarkin gravatar imageGregLarkin ( 2015-07-24 13:05:49 -0600 )edit

Please post your .fixtures.yml file somewhere for review.

GregLarkin gravatar imageGregLarkin ( 2015-07-24 13:06:01 -0600 )edit

I installed gem "puppetlabs_spec_helper" but when I run "rake spec" getting an error "/usr/bin/ruby -I/usr/lib/ruby/gems/1.8/gems/rspec-support-3.3.0/lib:/usr/lib/ruby/gems/1.8/gems/rspec-core-3.3.2/lib /usr/lib/ruby/gems/1.8/gems/rspec-core-3.3.2/exe/rspec --pattern spec/\*/\*_spec.rb"

Chutki gravatar imageChutki ( 2015-07-27 11:48:06 -0600 )edit

Please post your .fixtures.yml file somewhere for review.

GregLarkin gravatar imageGregLarkin ( 2015-07-27 15:55:56 -0600 )edit

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


Asked: 2015-07-23 06:44:02 -0600

Seen: 914 times

Last updated: Jul 31 '15