doubt is rspec-puppet concept continue

asked 2015-07-01 07:40:42 -0600

Chutki gravatar image


Please find the below file for sudo rspec-puppet test case

example I

require 'spec_helper'

describe 'sudo' do

  it { should contain_class('sudo')}

      it {should contain_file('/etc/sudoers').with(
        'ensure'  => 'present',
        'owner'   => 'root',
        'group'   => 'root',
        'mode'    => '0440')}

      it {should contain_file('/etc/sudoers').with_content( /Defaults    requiretty/) }


if I add "puppelabs" instead of "Defaults requiretty"

eg  it {should contain_file('/etc/sudoers').with_content( /puppetlabs/) }

getting below error

 Failure/Error: it {should contain_file('/etc/sudoers').with_content( /puppet labs/) }
       expected that the catalogue would contain File[/etc/sudoers] with content set to /puppet labs/ but it is set to "Defaults

example II

but when I run the below rspec-puppet, its executing without any error.But the actual value fqdn ( and hostname (puppet) is not present in /etc/hosts file

 let :facts do
      :fqdn      => '',
      :hostname  => 'puppet',
      :ipaddress => ''

    it {
      should contain_host('').with(
        'ensure'       => 'present',
        'host_aliases' => 'puppet',
        'ip'           => ''

So my doubt is, how come my example II rspec-puppet running even though the value is not present in /etc/hosts. Because in the first example I it was thorowing an error since it comparing the actual file /etc/sudoers file

edit retag flag offensive close merge delete


is there any update on this

Chutki gravatar imageChutki ( 2015-07-08 02:40:27 -0600 )edit