Skip to content

Instantly share code, notes, and snippets.

Created May 28, 2013 12:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5662336 to your computer and use it in GitHub Desktop.
Save anonymous/5662336 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Puppet::Type.type(:cq5bundle) do
before :each do
@bundle = Puppet::Type.type(:cq5bundle).new(:name => 'my.super.bundle', :ensure => 'running', :admin_user => 'admin', :admin_password => 'pass')
end
## Type should accept a name
it 'does accept a name' do
@bundle[:name] = 'my.super.bundle'
@bundle[:name].should == 'my.super.bundle'
end
## Type should reject a invalid name
it 'does not accept a invalid name' do
expect {
Puppet::Type.type(:cq5bundle).new(:name => 'my/super(bundle', :ensure => 'running', :admin_user => 'admin', :admin_password => 'pass')
}.to raise_error(Puppet::Error, /Parameter name failed/)
end
## Ensure matrix: Valid are :present, :running, :abesent, :stopped
{:present => [:present, :running], :absent => [:absent, :stopped]}.each do |output, input|
input.each do |i|
it "does accept ensure => :#{i}" do
@bundle[:ensure] = i
@bundle[:ensure].should == output
end
end
end
## :ensure property method change_to_s returns running, based on ensure value
{:present => :running, :absent => :stopped}.each do |k, v|
it "does return change value based on ensure" do
@bundle.parameter(:ensure).change_to_s(:bozo, k).should == v
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment