Class: ElabsMatchers::Matchers::Allow::AllowMatcher
- Inherits:
-
Object
- Object
- ElabsMatchers::Matchers::Allow::AllowMatcher
- Defined in:
- lib/elabs_matchers/matchers/allow.rb
Instance Attribute Summary (collapse)
-
- (Object) attributes
readonly
Returns the value of attribute attributes.
-
- (Object) record
readonly
Returns the value of attribute record.
Instance Method Summary (collapse)
-
- (Object) as(*attributes)
Tell the matcher which attributes to check.
- - (Boolean) does_not_match?(record)
- - (Object) failure_message_for_should
- - (Object) failure_message_for_should_not
-
- (AllowMatcher) initialize(values)
constructor
A new instance of AllowMatcher.
- - (Boolean) matches?(record)
Constructor Details
- (AllowMatcher) initialize(values)
A new instance of AllowMatcher
10 11 12 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 10 def initialize(values) @values = values end |
Instance Attribute Details
- (Object) attributes (readonly)
Returns the value of attribute attributes
8 9 10 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 8 def attributes @attributes end |
- (Object) record (readonly)
Returns the value of attribute record
8 9 10 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 8 def record @record end |
Instance Method Details
- (Object) as(*attributes)
Tell the matcher which attributes to check
Example: post.should allow("Elabs").as(:title)
33 34 35 36 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 33 def as(*attributes) @attributes = [*attributes] self end |
- (Boolean) does_not_match?(record)
19 20 21 22 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 19 def does_not_match?(record) @record = record errors.all? and correct_number_of_errors? end |
- (Object) failure_message_for_should
38 39 40 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 38 def (:valid) end |
- (Object) failure_message_for_should_not
42 43 44 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 42 def (:invalid) end |
- (Boolean) matches?(record)
14 15 16 17 |
# File 'lib/elabs_matchers/matchers/allow.rb', line 14 def matches?(record) @record = record errors.none? end |