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.



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

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

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



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

def actual
  @actual
end

#expectedObject (readonly)

Returns the value of attribute expected.



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

def expected
  @expected
end

#negativeObject (readonly)

Returns the value of attribute negative.



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

def negative
  @negative
end

#paramObject (readonly)

Returns the value of attribute param.



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

def param
  @param
end

Instance Method Details

#messageObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rspec-puppet/errors.rb', line 15

def message
  if (@param.to_s == 'content') && expected.is_a?(String)
    if negative == true
      "#{param} not set to supplied string"
    else
      "#{param} set to supplied string"
    end
  elsif negative == true
    "#{param} not set to #{expected.inspect} but it is set to #{actual.inspect}"
  else
    "#{param} set to #{expected.inspect} but it is set to #{actual.inspect}"
  end
end

#to_sObject



29
30
31
# File 'lib/rspec-puppet/errors.rb', line 29

def to_s
  message
end