Exception: RSpec::Puppet::Errors::MatchError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rspec-puppet/errors.rb

Direct Known Subclasses

ProcMatchError, RegexpMatchError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param, expected, actual, negative) ⇒ MatchError

Returns a new instance of MatchError.



6
7
8
9
10
11
# File 'lib/rspec-puppet/errors.rb', line 6

def initialize(param, expected, actual, negative)
  @param = param
  @expected = expected.inspect
  @actual = actual.inspect
  @negative = negative
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



4
5
6
# File 'lib/rspec-puppet/errors.rb', line 4

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



4
5
6
# File 'lib/rspec-puppet/errors.rb', line 4

def expected
  @expected
end

#negativeObject (readonly)

Returns the value of attribute negative.



4
5
6
# File 'lib/rspec-puppet/errors.rb', line 4

def negative
  @negative
end

#paramObject (readonly)

Returns the value of attribute param.



4
5
6
# File 'lib/rspec-puppet/errors.rb', line 4

def param
  @param
end

Instance Method Details

#messageObject



13
14
15
16
17
18
19
# File 'lib/rspec-puppet/errors.rb', line 13

def message
  if negative == true
    "#{param} not set to #{expected} but it is set to #{actual}"
  else
    "#{param} set to #{expected} but it is set to #{actual}"
  end
end

#to_sObject



21
22
23
# File 'lib/rspec-puppet/errors.rb', line 21

def to_s
  message
end