Class: Ward::Matchers::Acceptance
- Defined in:
- lib/ward/matchers/acceptance.rb
Overview
Tests whether the validation value is accepted.
An “accepted” value one which is exactly true, “t”, “true”, “1”, “y”, or “yes”.
Instance Attribute Summary
Attributes inherited from Matcher
Instance Method Summary collapse
-
#initialize(expected = nil, *extra_args) ⇒ Acceptance
constructor
Creates a new matcher instance.
-
#matches?(actual) ⇒ Boolean
Returns whether the given value is accepted.
Methods inherited from Matcher
#customise_error_values, error_id
Constructor Details
#initialize(expected = nil, *extra_args) ⇒ Acceptance
Creates a new matcher instance.
23 24 25 26 27 28 |
# File 'lib/ward/matchers/acceptance.rb', line 23 def initialize(expected = nil, *extra_args) expected = Array(expected || %w( t true y yes 1 ) + [1]) @include_matcher = Include.new(expected) super(expected, *extra_args) end |
Instance Method Details
#matches?(actual) ⇒ Boolean
Returns whether the given value is accepted.
37 38 39 |
# File 'lib/ward/matchers/acceptance.rb', line 37 def matches?(actual) actual == true or @include_matcher.matches?(actual) end |