class RSpec::Puppet::TypeAliasMatchers::AllowValue

Public Class Methods

new(values) click to toggle source
# File lib/rspec-puppet/matchers/allow_value.rb, line 4
def initialize(values)
  @values = values
  @error_msgs = []
end

Public Instance Methods

description() click to toggle source
# File lib/rspec-puppet/matchers/allow_value.rb, line 22
def description
  if @values.length == 1
    "match value #{@values.first.inspect}"
  else
    "match values #{@values.map(&:inspect).join(', ')}"
  end
end
failure_message() click to toggle source
# File lib/rspec-puppet/matchers/allow_value.rb, line 30
def failure_message
  "expected that the type alias would " + description + " but it raised the #{@error_msgs.length == 1 ? 'error' : 'errors'} #{@error_msgs.join(', ')}"
end
failure_message_when_negated() click to toggle source
# File lib/rspec-puppet/matchers/allow_value.rb, line 34
def failure_message_when_negated
  "expected that the type alias would not " + description + " but it does"
end
matches?(catalogue) click to toggle source
# File lib/rspec-puppet/matchers/allow_value.rb, line 9
def matches?(catalogue)
  matches = @values.map do |test_value|
    begin
      catalogue.call(test_value)
      true
    rescue Puppet::Error => e
      @error_msgs << e.message
      false
    end
  end
  matches.all?
end
supports_block_expectations() click to toggle source
# File lib/rspec-puppet/matchers/allow_value.rb, line 38
def supports_block_expectations
  true
end
supports_value_expectations() click to toggle source
# File lib/rspec-puppet/matchers/allow_value.rb, line 42
def supports_value_expectations
  true
end