Sha256: 98da3327d06a706f3d6baeb2ea71a52b8063f0d57c8e814bbf9379aff61f9a9d

Contents?: true

Size: 892 Bytes

Versions: 340

Compression:

Stored size: 892 Bytes

Contents

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
    expect(@tester).to respond_to(:fail)
  end

  it "should provide a 'devfail' method" do
    expect(@tester).to respond_to(:devfail)
  end

  it "should raise any provided error when failing" do
    expect { @tester.fail(Puppet::ParseError, "stuff") }.to raise_error(Puppet::ParseError)
  end

  it "should default to Puppet::Error when failing" do
    expect { @tester.fail("stuff") }.to 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
    expect(@tester.error_context).to eq(" (file: /my/file, line: 50)")
  end
end

Version data entries

340 entries across 340 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/util/errors_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/util/errors_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/util/errors_spec.rb
puppet-8.3.0-universal-darwin spec/unit/util/errors_spec.rb
puppet-8.4.0 spec/unit/util/errors_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/util/errors_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/util/errors_spec.rb
puppet-8.4.0-universal-darwin spec/unit/util/errors_spec.rb
puppet-7.28.0 spec/unit/util/errors_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/util/errors_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/util/errors_spec.rb
puppet-7.28.0-universal-darwin spec/unit/util/errors_spec.rb
puppet-8.3.1 spec/unit/util/errors_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/util/errors_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/util/errors_spec.rb
puppet-8.3.1-universal-darwin spec/unit/util/errors_spec.rb
puppet-7.27.0 spec/unit/util/errors_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/util/errors_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/util/errors_spec.rb
puppet-7.27.0-universal-darwin spec/unit/util/errors_spec.rb