Class: RSpecJSONAPISerializer::Matchers::AssociationMatcher
- Defined in:
- lib/rspec_jsonapi_serializer/matchers/association_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #id_method_name(value) ⇒ Object
-
#initialize(expected, relationship_matcher, relationship_type) ⇒ AssociationMatcher
constructor
A new instance of AssociationMatcher.
- #matches?(serializer_instance) ⇒ Boolean
- #object_method_name(value) ⇒ Object
- #serializer(value) ⇒ Object
Constructor Details
#initialize(expected, relationship_matcher, relationship_type) ⇒ AssociationMatcher
Returns a new instance of AssociationMatcher.
12 13 14 15 16 17 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 12 def initialize(expected, relationship_matcher, relationship_type) super(expected) @relationship_matcher = relationship_matcher @relationship_type = relationship_type end |
Instance Method Details
#description ⇒ Object
43 44 45 46 47 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 43 def description description = "#{} #{expected}" [description, submatchers.map(&:description)].flatten.join(' ') end |
#failure_message ⇒ Object
49 50 51 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 49 def "Expected #{expectation}" end |
#failure_message_when_negated ⇒ Object
53 54 55 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 53 def "Did not expect #{expectation}" end |
#id_method_name(value) ⇒ Object
31 32 33 34 35 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 31 def id_method_name(value) add_submatcher AssociationMatchers::IdMethodNameMatcher.new(value, expected) self end |
#matches?(serializer_instance) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 19 def matches?(serializer_instance) @serializer_instance = serializer_instance relationship_matches? && submatchers_match? end |
#object_method_name(value) ⇒ Object
37 38 39 40 41 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 37 def object_method_name(value) add_submatcher AssociationMatchers::ObjectMethodNameMatcher.new(value, expected) self end |
#serializer(value) ⇒ Object
25 26 27 28 29 |
# File 'lib/rspec_jsonapi_serializer/matchers/association_matcher.rb', line 25 def serializer(value) add_submatcher AssociationMatchers::SerializerMatcher.new(value, expected) self end |