File: enum_setting_spec.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (27 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (4)
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
require 'spec_helper'

require 'puppet/settings'

describe Puppet::Settings::EnumSetting do
  it "allows a configured value" do
    setting = enum_setting_allowing("allowed")

    expect(setting.munge("allowed")).to eq("allowed")
  end

  it "disallows a value that is not configured" do
    setting = enum_setting_allowing("allowed", "also allowed")

    expect do
      setting.munge("disallowed")
    end.to raise_error(Puppet::Settings::ValidationError,
                       "Invalid value 'disallowed' for parameter testing. Allowed values are 'allowed', 'also allowed'")
  end

  def enum_setting_allowing(*values)
    Puppet::Settings::EnumSetting.new(:settings => double('settings'),
                                      :name => "testing",
                                      :desc => "description of testing",
                                      :values => values)
  end
end