Proof of concept

This commit is contained in:
Tim Sharpe 2011-07-16 16:15:28 +10:00
parent 3bbb83dc27
commit bcc7ffc6d2
4 changed files with 55 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.gem

View File

@ -0,0 +1,2 @@
require 'puppet'
require 'puppet-rspec/matchers/exec'

View File

@ -0,0 +1,34 @@
module PuppetRSpec
module Matchers
extend RSpec::Matchers::DSL
matcher :create_exec do |expected_title|
match do |catalogue|
ret = true
resources = catalogue.resources.select { |r|
r.title == expected_title if r.respond_to? :title
}
unless resources.length == 1
ret = false
end
unless @expected_command.nil?
unless resources.first.send(:parameters)[:command] == @expected_command
ret = false
end
end
ret
end
description do
"create Exec['#{expected_title}']"
end
failure_message_for_should do |actual|
"expected that the catalogue would contain Exec['#{expected_title}']"
end
chain :with_command do |expected_command|
@expected_command = expected_command
end
end
end
end

18
puppet-rspec.gemspec Normal file
View File

@ -0,0 +1,18 @@
Gem::Specification.new do |s|
s.name = 'puppet-rspec'
s.version = '0.0.1'
s.homepage = 'https://github.com/rodjek/puppet-rspec/'
s.summary = ''
s.description = ''
s.files = [
'puppet-rspec.gemspec',
'lib/puppet-rspec.rb',
'lib/puppet-rspec/matchers/exec.rb'
]
s.add_dependency 'rspec'
s.authors = ['Tim Sharpe']
s.email = 'tim@sharpe.id.au'
end