Last active
December 15, 2015 16:39
-
-
Save raphink/5290802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'catalog' | |
| describe 'package' do | |
| subject { Catalog.instance } | |
| # subject { YAML.load_file('/tmp/catalog') } | |
| it { should contain_package('augeas') } | |
| it { should contain_package('augeas-lenses') } | |
| it { should contain_package('augeas-tools') } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'puppet/node' | |
| require 'puppet/resource/catalog' | |
| require 'puppet/indirector/catalog/rest' | |
| require 'rubygems' | |
| require 'rspec' | |
| require 'rspec-puppet/matchers' | |
| require 'stringio' | |
| require 'catalog' | |
| class Puppet::Resource::Catalog::RestSpec < Puppet::Resource::Catalog::Rest | |
| def compiler | |
| @compiler ||= indirection.terminus(:rest) | |
| #@compiler ||= indirection.terminus(:yaml) | |
| end | |
| def find(request) | |
| return nil unless catalog = compiler.find(request) | |
| RSpec::configure do |c| | |
| c.include(RSpec::Puppet::ManifestMatchers) | |
| end | |
| # TODO: try to pass the catalog to the examples | |
| Catalog.setup('foo') | |
| # Test by classes, including $certname | |
| spec_dirs = [] | |
| catalog.classes.each do |c| | |
| class_dir = c.gsub(/:/, '_') | |
| class_path = "#{Puppet.settings[:libdir]}/spec/class/#{class_dir}" | |
| spec_dirs << class_path if File.directory? class_path | |
| end | |
| out = StringIO.new | |
| unless RSpec::Core::Runner::run(spec_dirs, $stderr, out) == 0 | |
| raise Puppet::Error, "Unit tests failed:\n#{out.string}" | |
| end | |
| catalog | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment