diff options
Diffstat (limited to 'spec/lib/puppet_spec')
| -rw-r--r-- | spec/lib/puppet_spec/language.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/puppet_spec/language.rb b/spec/lib/puppet_spec/language.rb index 09d88a851..197c4b827 100644 --- a/spec/lib/puppet_spec/language.rb +++ b/spec/lib/puppet_spec/language.rb @@ -2,9 +2,13 @@ require 'puppet_spec/compiler' require 'matchers/resource' module PuppetSpec::Language + extend RSpec::Matchers::DSL + def produces(expectations) + calledFrom = caller expectations.each do |manifest, resources| it "evaluates #{manifest} to produce #{resources}" do + begin case resources when String node = Puppet::Node.new('specification') @@ -41,16 +45,29 @@ module PuppetSpec::Language else raise "Unsupported creates specification: #{resources.inspect}" end + rescue Puppet::Error, RSpec::Expectations::ExpectationNotMetError => e + # provide the backtrace from the caller, or it is close to impossible to find some originators + e.set_backtrace(calledFrom) + raise + end + end end end def fails(expectations) + calledFrom = caller expectations.each do |manifest, pattern| it "fails to evaluate #{manifest} with message #{pattern}" do + begin expect do PuppetSpec::Compiler.compile_to_catalog(manifest) end.to raise_error(Puppet::Error, pattern) + rescue RSpec::Expectations::ExpectationNotMetError => e + # provide the backgrace from the caller, or it is close to impossible to find some originators + e.set_backtrace(calledFrom) + raise + end end end end |
