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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
require 'spec_helper'
describe 'fake' do
let :title do
'foo'
end
it { should be_valid_type }
describe 'tests of the types' do
{
:parameters =>
{:baddies => ['one', 'two'], :goodies => ['three', 'four']},
:properties =>
{:baddies => ['five', 'fix'], :goodies => ['seven', 'eight']},
:features =>
{:baddies => ['nine', 'ten'], :goodies => ['eleven', 'twelve']}
}.each do |k, v|
describe "#{k} checks" do
[v[:baddies], v[:baddies].first].each do |baddies|
it "should fail for #{baddies.size} baddies" do
expect do
should be_valid_type.send("with_#{k}".to_sym, baddies)
end.to raise_error(
RSpec::Expectations::ExpectationNotMetError,
/Invalid #{k}: #{Array(baddies).join(',')}/
)
end
end
[v[:goodies], v[:goodies].first].each do |goodies|
it "should pass with #{goodies.size} goodies" do
should be_valid_type.send("with_#{k}".to_sym, goodies)
end
end
end
end
end
describe 'tests that create a resource instance' do
let :params do
{ :three => 'value' }
end
it 'should pass when providers match' do
should be_valid_type.with_provider(:default)
end
it 'should fail when provider does not match' do
expect do
should be_valid_type.with_provider(:non_matching)
end.to raise_error(
RSpec::Expectations::ExpectationNotMetError,
/Expected provider: non_matching does not match: default/
)
end
it 'should pass when providers match' do
should be_valid_type.with_provider(:default)
end
it 'should fail with invalid parameters' do
expect do
should be_valid_type.with_set_attributes(
:four => 'three'
)
end.to raise_error(
Puppet::Error,
/Valid values match \/\(one\|two\)\//
)
end
it 'should not fail with valid parameters' do
should be_valid_type.with_set_attributes(
:four => 'one'
)
end
end
end
|