Class: JSONAPI::Resources::Matchers::HaveCreatableField
- Inherits:
-
Object
- Object
- JSONAPI::Resources::Matchers::HaveCreatableField
- Defined in:
- lib/jsonapi/resources/matchers/have_creatable_field.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(name) ⇒ HaveCreatableField
constructor
A new instance of HaveCreatableField.
- #matches?(resource) ⇒ Boolean
Constructor Details
#initialize(name) ⇒ HaveCreatableField
Returns a new instance of HaveCreatableField.
8 9 10 |
# File 'lib/jsonapi/resources/matchers/have_creatable_field.rb', line 8 def initialize(name) self.name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/jsonapi/resources/matchers/have_creatable_field.rb', line 6 def name @name end |
#resource ⇒ Object
Returns the value of attribute resource.
6 7 8 |
# File 'lib/jsonapi/resources/matchers/have_creatable_field.rb', line 6 def resource @resource end |
Instance Method Details
#description ⇒ Object
27 28 29 |
# File 'lib/jsonapi/resources/matchers/have_creatable_field.rb', line 27 def description "have creatable field `#{name}`" end |
#failure_message ⇒ Object
17 18 19 20 |
# File 'lib/jsonapi/resources/matchers/have_creatable_field.rb', line 17 def resource_name = resource.class.name.demodulize %Q(expected #{resource_name} to have creatable field `#{name}`) end |
#failure_message_when_negated ⇒ Object
22 23 24 25 |
# File 'lib/jsonapi/resources/matchers/have_creatable_field.rb', line 22 def resource_name = resource.class.name.demodulize %Q(expected #{resource_name} not to have creatable field `#{name}`) end |
#matches?(resource) ⇒ Boolean
12 13 14 15 |
# File 'lib/jsonapi/resources/matchers/have_creatable_field.rb', line 12 def matches?(resource) self.resource = resource resource.class.creatable_fields(resource.context).include?(name) end |