Class: ValidateOptions::Spec::Matchers::ValidateOptionsMatcher
- Inherits:
-
Object
- Object
- ValidateOptions::Spec::Matchers::ValidateOptionsMatcher
- Defined in:
- lib/validate_options/spec.rb
Overview
:nodoc:
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(accepted_options) ⇒ ValidateOptionsMatcher
constructor
A new instance of ValidateOptionsMatcher.
- #matches?(target) ⇒ Boolean
Constructor Details
#initialize(accepted_options) ⇒ ValidateOptionsMatcher
Returns a new instance of ValidateOptionsMatcher.
5 6 7 |
# File 'lib/validate_options/spec.rb', line 5 def initialize() @accepted_options = end |
Instance Method Details
#failure_message ⇒ Object
29 30 31 |
# File 'lib/validate_options/spec.rb', line 29 def "expected block to validate options." end |
#matches?(target) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/validate_options/spec.rb', line 9 def matches?(target) accepted = @accepted_options.all? do |opt| begin target.call(opt => nil) true rescue ArgumentError false end end rejected = begin target.call("___very_odd_probably_invalid_key" => nil) false rescue ArgumentError true end accepted && rejected end |