diff options
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/util/errors.rb | 38 | ||||
| -rwxr-xr-x | spec/unit/util/inline_docs.rb | 2 |
2 files changed, 39 insertions, 1 deletions
diff --git a/spec/unit/util/errors.rb b/spec/unit/util/errors.rb new file mode 100755 index 000000000..e30b85db5 --- /dev/null +++ b/spec/unit/util/errors.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +require 'puppet/util/errors' + +class ErrorTester + include Puppet::Util::Errors + attr_accessor :line, :file +end + +describe Puppet::Util::Errors do + before do + @tester = ErrorTester.new + end + + it "should provide a 'fail' method" do + @tester.should respond_to(:fail) + end + + it "should provide a 'devfail' method" do + @tester.should respond_to(:devfail) + end + + it "should raise any provided error when failing" do + lambda { @tester.fail(Puppet::ParseError, "stuff") }.should raise_error(Puppet::ParseError) + end + + it "should default to Puppet::Error when failing" do + lambda { @tester.fail("stuff") }.should raise_error(Puppet::Error) + end + + it "should have a method for converting error context into a string" do + @tester.file = "/my/file" + @tester.line = 50 + @tester.error_context.should == " at /my/file:50" + end +end diff --git a/spec/unit/util/inline_docs.rb b/spec/unit/util/inline_docs.rb index c541d01f0..a03939ee1 100755 --- a/spec/unit/util/inline_docs.rb +++ b/spec/unit/util/inline_docs.rb @@ -2,7 +2,7 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } -require 'puppet/util/file_locking' +require 'puppet/util/inline_docs' class InlineDoccer include Puppet::Util::InlineDocs |
