doubt is rspec-puppet concept continue

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

Chutki gravatar image

Hi,

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/) }

    end
  end

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 ( puppet.example.com) and hostname (puppet) is not present in /etc/hosts file

 let :facts do
     {
      :fqdn      => 'puppet.example.com',
      :hostname  => 'puppet',
      :ipaddress => 'xxx.yy.ee.zzz'
     }
    end

    it {
      should contain_host('puppet.example.com').with(
        'ensure'       => 'present',
        'host_aliases' => 'puppet',
        'ip'           => 'xxx.yy.ee.zzz'
      )

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

Comments

is there any update on this

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