Class: RSpec::Puppet::TypeAliasMatchers::AllowValue
- Inherits:
-
Object
- Object
- RSpec::Puppet::TypeAliasMatchers::AllowValue
- Defined in:
- lib/rspec-puppet/matchers/allow_value.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(values) ⇒ AllowValue
constructor
A new instance of AllowValue.
- #matches?(catalogue) ⇒ Boolean
- #supports_block_expectations ⇒ Object
- #supports_value_expectations ⇒ Object
Constructor Details
#initialize(values) ⇒ AllowValue
Returns a new instance of AllowValue.
6 7 8 9 |
# File 'lib/rspec-puppet/matchers/allow_value.rb', line 6 def initialize(values) @values = values @error_msgs = [] end |
Instance Method Details
#description ⇒ Object
22 23 24 25 26 27 28 |
# 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 ⇒ Object
30 31 32 |
# File 'lib/rspec-puppet/matchers/allow_value.rb', line 30 def "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 ⇒ Object
34 35 36 |
# File 'lib/rspec-puppet/matchers/allow_value.rb', line 34 def "expected that the type alias would not #{description} but it does" end |
#matches?(catalogue) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rspec-puppet/matchers/allow_value.rb', line 11 def matches?(catalogue) matches = @values.map do |test_value| catalogue.call(test_value) true rescue Puppet::Error => e @error_msgs << e. false end matches.all? end |
#supports_block_expectations ⇒ Object
38 39 40 |
# File 'lib/rspec-puppet/matchers/allow_value.rb', line 38 def supports_block_expectations true end |
#supports_value_expectations ⇒ Object
42 43 44 |
# File 'lib/rspec-puppet/matchers/allow_value.rb', line 42 def supports_value_expectations true end |