Class: Remarkable::Mongoid::Matchers::HasFieldMatcher
- Inherits:
-
Object
- Object
- Remarkable::Mongoid::Matchers::HasFieldMatcher
- Defined in:
- lib/remarkable/mongoid/fields.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(field, options) ⇒ HasFieldMatcher
constructor
A new instance of HasFieldMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(field, options) ⇒ HasFieldMatcher
Returns a new instance of HasFieldMatcher.
22 23 24 25 |
# File 'lib/remarkable/mongoid/fields.rb', line 22 def initialize(field, ) self.field = field.to_s self. = { :type => Object }.merge() end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
20 21 22 |
# File 'lib/remarkable/mongoid/fields.rb', line 20 def field @field end |
#options ⇒ Object
Returns the value of attribute options.
20 21 22 |
# File 'lib/remarkable/mongoid/fields.rb', line 20 def @options end |
Instance Method Details
#description ⇒ Object
32 33 34 |
# File 'lib/remarkable/mongoid/fields.rb', line 32 def description "have field #{field} #{}" end |
#failure_message_for_should ⇒ Object
36 37 38 |
# File 'lib/remarkable/mongoid/fields.rb', line 36 def "expected #{@subject} to have field #{field} #{}" end |
#failure_message_for_should_not ⇒ Object
40 41 42 |
# File 'lib/remarkable/mongoid/fields.rb', line 40 def "expected #{@subject} to not have field #{field} #{}" end |
#matches?(subject) ⇒ Boolean
27 28 29 30 |
# File 'lib/remarkable/mongoid/fields.rb', line 27 def matches?(subject) @subject = subject.is_a?(Class) ? subject : subject.class @subject.fields.has_key?(field) && (@subject.fields[field].type == [:type]) end |