Sha256: 1c028fbf3e12b187ba66761591ccb410ad99856f04d4556bf298b36599429942

Contents?: true

Size: 1021 Bytes

Versions: 19

Compression:

Stored size: 1021 Bytes

Contents

#!/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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/util/errors_spec.rb
puppet-2.6.17 spec/unit/util/errors_spec.rb
puppet-2.6.16 spec/unit/util/errors_spec.rb
puppet-2.6.15 spec/unit/util/errors_spec.rb
puppet-2.6.14 spec/unit/util/errors_spec.rb
puppet-2.6.13 spec/unit/util/errors_spec.rb
puppet-2.6.12 spec/unit/util/errors_spec.rb
puppet-2.6.11 spec/unit/util/errors_spec.rb
puppet-2.6.10 spec/unit/util/errors_spec.rb
puppet-2.6.9 spec/unit/util/errors_spec.rb
puppet-2.6.8 spec/unit/util/errors_spec.rb
puppet-2.6.7 spec/unit/util/errors_spec.rb
puppet-2.6.6 spec/unit/util/errors_spec.rb
puppet-2.6.5 spec/unit/util/errors_spec.rb
puppet-2.6.4 spec/unit/util/errors_spec.rb
puppet-2.6.3 spec/unit/util/errors_spec.rb
puppet-2.6.2 spec/unit/util/errors_spec.rb
puppet-2.6.1 spec/unit/util/errors_spec.rb
puppet-2.6.0 spec/unit/util/errors_spec.rb