summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/errors_spec.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-06-28 17:10:20 -0700
committerMarkus Roberts <Markus@reality.com>2010-06-28 17:10:20 -0700
commitfdc8c3509b5ac5bc170c54d72b2c2bafb58409f2 (patch)
tree6ed2204d72c6924e867a1320d3b7e6728035f1a1 /spec/unit/util/errors_spec.rb
parent9a94ee274c39c261cd49e688a7bd7ea0eb73af50 (diff)
downloadpuppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.tar.gz
puppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.tar.xz
puppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.zip
[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rb
Part 2 re-did the change on the spec files, which it shouldn't have.
Diffstat (limited to 'spec/unit/util/errors_spec.rb')
-rwxr-xr-xspec/unit/util/errors_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/util/errors_spec.rb b/spec/unit/util/errors_spec.rb
new file mode 100755
index 000000000..e30b85db5
--- /dev/null
+++ b/spec/unit/util/errors_spec.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