File: default_content_spec.rb

package info (click to toggle)
puppet-module-extlib 7.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: ruby: 1,035; sh: 15; makefile: 10
file content (35 lines) | stat: -rw-r--r-- 1,148 bytes parent folder | download
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
# frozen_string_literal: true

require 'spec_helper'

describe 'extlib::default_content' do
  it { is_expected.not_to eq(nil) }
  it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
  it { is_expected.to run.with_params(:undef, :undef).and_return(:undef) }

  describe 'signature validation' do
    it 'exists' do
      is_expected.not_to be_nil
    end
  end

  context 'should return the correct string for' do
    it 'a string' do
      is_expected.to run.with_params('a string', :undef).and_return 'a string'
    end

    it 'an empty string and an epp template' do
      File.write('/tmp/foo.epp', '<% $foo = 2 %>a template string <%= $foo + 1 %>')
      is_expected.to run.with_params(:undef, '/tmp/foo.epp').and_return 'a template string 3'
    end

    it 'an empty string and an erb template' do
      File.write('/tmp/foo.erb', '<% @foo = 1 %>a template string <%= @foo + 1 %>')
      is_expected.to run.with_params(:undef, '/tmp/foo.erb').and_return 'a template string 2'
    end

    it 'an empty string and an empty template' do
      is_expected.to run.with_params(:undef, :undef).and_return :undef
    end
  end
end