File: function_example_group_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 (47 lines) | stat: -rw-r--r-- 1,312 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
46
47
require 'spec_helper'

if Puppet.version.to_f >= 4.0
  describe RSpec::Puppet::FunctionExampleGroup::V4FunctionWrapper do
    let(:name) { 'test_function' }
    let(:func) { double('func') }
    let(:global_scope) { double('global_scope') }
    let(:overrides) { { :global_scope => global_scope } }

    describe 'when calling with params' do
      subject { described_class.new(name, func, overrides) }
      it do
        expect(func).to receive(:call).with(global_scope, 1, 2).once
        subject.call({}, 1, 2)
      end
    end

    describe 'when executing with params' do
      subject { described_class.new(name, func, overrides) }
      it do
        expect(func).to receive(:call).with(global_scope, 1, 2).once
        subject.execute(1, 2)
      end
    end
  end
end

describe RSpec::Puppet::FunctionExampleGroup::V3FunctionWrapper do
  let(:name) { 'test_function' }
  let(:func) { double('func') }

  describe 'when calling with params' do
    subject { described_class.new(name, func) }
    it do
      expect(func).to receive(:call).with([1, 2]).once
      subject.call([1, 2])
    end
  end

  describe 'when executing with params' do
    subject { described_class.new(name, func) }
    it do
      expect(func).to receive(:call).with([1, 2]).once
      subject.execute(1, 2)
    end
  end
end