Class: JSONAPI::Resources::Matchers::HaveModelName
- Inherits:
-
Object
- Object
- JSONAPI::Resources::Matchers::HaveModelName
- Defined in:
- lib/jsonapi/resources/matchers/have_model_name.rb
Instance Attribute Summary collapse
-
#expected_model_name ⇒ Object
Returns the value of attribute expected_model_name.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(name) ⇒ HaveModelName
constructor
A new instance of HaveModelName.
- #matches?(resource) ⇒ Boolean
Constructor Details
#initialize(name) ⇒ HaveModelName
Returns a new instance of HaveModelName.
8 9 10 |
# File 'lib/jsonapi/resources/matchers/have_model_name.rb', line 8 def initialize(name) self.expected_model_name = name end |
Instance Attribute Details
#expected_model_name ⇒ Object
Returns the value of attribute expected_model_name.
6 7 8 |
# File 'lib/jsonapi/resources/matchers/have_model_name.rb', line 6 def expected_model_name @expected_model_name end |
#resource ⇒ Object
Returns the value of attribute resource.
6 7 8 |
# File 'lib/jsonapi/resources/matchers/have_model_name.rb', line 6 def resource @resource end |
Instance Method Details
#description ⇒ Object
17 18 19 |
# File 'lib/jsonapi/resources/matchers/have_model_name.rb', line 17 def description %Q(have model name `#{expected_model_name}`) end |
#failure_message ⇒ Object
21 22 23 24 |
# File 'lib/jsonapi/resources/matchers/have_model_name.rb', line 21 def resource_name = resource.class.name.demodulize %Q(expected `#{resource_name}` to have the model name `#{expected_model_name}`) end |
#matches?(resource) ⇒ Boolean
12 13 14 15 |
# File 'lib/jsonapi/resources/matchers/have_model_name.rb', line 12 def matches?(resource) self.resource = resource self.resource.class._model_name.to_s == self.expected_model_name.to_s end |