Sha256: f174c918585e571cc746a75a29d4dfcabfc98f0836760bb61ba3b2626a04a5ee

Contents?: true

Size: 905 Bytes

Versions: 4

Compression:

Stored size: 905 Bytes

Contents

#! /usr/bin/env ruby -S rspec
require 'spec_helper'

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

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 spec/unit/util/errors_spec.rb
puppet-3.0.0.rc7 spec/unit/util/errors_spec.rb
puppet-3.0.0.rc5 spec/unit/util/errors_spec.rb
puppet-3.0.0.rc4 spec/unit/util/errors_spec.rb