File: facter_impl_spec.rb

package info (click to toggle)
puppet-agent 7.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,092 kB
  • sloc: ruby: 245,074; sh: 456; makefile: 38; xml: 33
file content (31 lines) | stat: -rw-r--r-- 790 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
require 'spec_helper'

describe 'Puppet::FacterImpl' do
  subject(:facter_impl) { Puppet::FacterImpl.new }

  it { is_expected.to respond_to(:value) }
  it { is_expected.to respond_to(:add) }

  describe '.value' do
    let(:method_name) { :value }

    before { allow(Facter).to receive(method_name) }

    it 'delegates to Facter API' do
      facter_impl.value('test_fact')
      expect(Facter).to have_received(method_name).with('test_fact')
    end
  end

  describe '.add' do
    let(:block) { Proc.new { setcode 'test' } }
    let(:method_name) { :add }

    before { allow(Facter).to receive(method_name) }

    it 'delegates to Facter API' do
      facter_impl.add('test_fact', &block)
      expect(Facter).to have_received(method_name).with('test_fact', &block)
    end
  end
end