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
  @actual = actual
  @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
20
21
22
23
24
25
26
27
# File 'lib/rspec-puppet/errors.rb', line 13

def message
  if @param.to_s == 'content' and expected.is_a?( String )
    if negative == true
      "#{param} not set to supplied string"
    else
      "#{param} set to supplied string"
    end
  else
    if 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
end

#to_sObject



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

def to_s
  message
end