File: test_basic_spec.rb

package info (click to toggle)
ruby-rspec-puppet 2.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,416 kB
  • sloc: ruby: 6,661; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'spec_helper'

describe 'test::basic' do
  it { should contain_fake('foo').with_three([{'foo' => 'bar'}]) }

  context 'testing node based facts' do
    let(:pre_condition) { 'notify { $::fqdn: }' }
    let(:node) { 'test123.test.com' }
    let(:facts) do
      {
        :fqdn       => 'notthis.test.com',
        :networking => {
          :primary => 'eth0',
        },
      }
    end

    it { should contain_notify('test123.test.com') }
    it { should_not contain_notify('notthis.test.com') }

    context 'existing networking facts should not be clobbered', :if => Puppet.version.to_f >= 4.0 do
      let(:pre_condition) { 'notify { [$facts["networking"]["primary"], $facts["networking"]["hostname"]]: }' }

      it { should contain_notify('eth0') }
      it { should contain_notify('test123') }
    end

    context 'when derive_node_facts_from_nodename => false' do
      let(:pre_condition) { 'notify { $::fqdn: }' }
      let(:node) { 'mycertname.test.com' }
      let(:facts) do
        {
          :fqdn => 'myhostname.test.com',
        }
      end

      before do
        RSpec.configuration.derive_node_facts_from_nodename = false
      end

      it { should contain_notify('myhostname.test.com') }
      it { should_not contain_notify('mycertname.test.com') }
    end
  end
end