Sha256: 06e4602fe911f828ed27277b65e2f9fa8dd54b3e7449f4487c3c2f8269ac2b89

Contents?: true

Size: 1.07 KB

Versions: 278

Compression:

Stored size: 1.07 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet'
require 'puppet/parameter/boolean'

describe Puppet::Parameter::Boolean do
  let (:resource) { mock('resource') }
  describe "after initvars" do
    before { described_class.initvars }
    it "should have the correct value_collection" do
      expect(described_class.value_collection.values.sort).to eq(
          [:true, :false, :yes, :no].sort
      )
    end
  end

  describe "instances" do
    subject { described_class.new(:resource => resource) }

    [ true, :true, 'true', :yes, 'yes', 'TrUe', 'yEs' ].each do |arg|
      it "should munge #{arg.inspect} as true" do
        expect(subject.munge(arg)).to eq(true)
      end
    end
    [ false, :false, 'false', :no, 'no', 'FaLSE', 'nO' ].each do |arg|
      it "should munge #{arg.inspect} as false" do
        expect(subject.munge(arg)).to eq(false)
      end
    end
    [ nil, :undef, 'undef', '0', 0, '1', 1, 9284 ].each do |arg|
      it "should fail to munge #{arg.inspect}" do
        expect { subject.munge(arg) }.to raise_error Puppet::Error
      end
    end
  end
end

Version data entries

278 entries across 278 versions & 1 rubygems

Version Path
puppet-6.0.5 spec/unit/parameter/boolean_spec.rb
puppet-6.0.5-x86-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-6.0.5-x64-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-6.0.5-universal-darwin spec/unit/parameter/boolean_spec.rb
puppet-5.5.10 spec/unit/parameter/boolean_spec.rb
puppet-5.5.10-x86-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-5.5.10-x64-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-5.5.10-universal-darwin spec/unit/parameter/boolean_spec.rb
puppet-6.1.0 spec/unit/parameter/boolean_spec.rb
puppet-6.1.0-x86-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-6.1.0-x64-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-6.1.0-universal-darwin spec/unit/parameter/boolean_spec.rb
puppet-6.0.4 spec/unit/parameter/boolean_spec.rb
puppet-6.0.4-x86-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-6.0.4-x64-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-6.0.4-universal-darwin spec/unit/parameter/boolean_spec.rb
puppet-5.5.8 spec/unit/parameter/boolean_spec.rb
puppet-5.5.8-x86-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-5.5.8-x64-mingw32 spec/unit/parameter/boolean_spec.rb
puppet-5.5.8-universal-darwin spec/unit/parameter/boolean_spec.rb