File: errors_spec.rb

package info (click to toggle)
puppet-agent 7.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,092 kB
  • sloc: ruby: 245,074; sh: 456; makefile: 38; xml: 33
file content (36 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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