rspec_jsonapi_serializer 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/rspec_jsonapi_serializer/matchers/association_matcher.rb +21 -5
 - data/lib/rspec_jsonapi_serializer/matchers/association_matchers/serializer_matcher.rb +6 -6
 - data/lib/rspec_jsonapi_serializer/matchers/base.rb +2 -22
 - data/lib/rspec_jsonapi_serializer/matchers/belong_to_matcher.rb +10 -2
 - data/lib/rspec_jsonapi_serializer/matchers/have_attribute_matcher.rb +22 -4
 - data/lib/rspec_jsonapi_serializer/matchers/have_attribute_matchers/as_matcher.rb +15 -5
 - data/lib/rspec_jsonapi_serializer/matchers/have_id_matcher.rb +1 -1
 - data/lib/rspec_jsonapi_serializer/matchers/have_link_matcher.rb +22 -4
 - data/lib/rspec_jsonapi_serializer/matchers/have_link_matchers/as_matcher.rb +15 -5
 - data/lib/rspec_jsonapi_serializer/matchers/have_many_matcher.rb +10 -2
 - data/lib/rspec_jsonapi_serializer/matchers/have_meta_matcher.rb +22 -4
 - data/lib/rspec_jsonapi_serializer/matchers/have_meta_matchers/as_matcher.rb +15 -4
 - data/lib/rspec_jsonapi_serializer/matchers/have_one_matcher.rb +10 -2
 - data/lib/rspec_jsonapi_serializer/matchers/have_type_matcher.rb +1 -1
 - data/lib/rspec_jsonapi_serializer/version.rb +1 -1
 - metadata +7 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 61f6a27fca68262e1efe72673c7519610c53c72de7f5aeb393c9ad5b32864bfd
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7f5745572ef15b1442df7d055802f5ffec3e5aac01c14b92e97e80db827f6387
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8f35c497af303a5802f192639b5d36997d6ea76626d7229cbc9d1990882f7163bdb5f6ac12e4f93e2990a95d9c21888ffa465e02ac5edc0a414ced5ef0c9dadf
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 7c0ba61d35ad01c788164f650a60b0d532f856cac08f05f974c33c04309b92d7656c776452d7b83418580c700b6f5accab09b6e8d8a7d40c923f848c73e87b29
         
     | 
| 
         @@ -26,16 +26,32 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       26 
26 
     | 
    
         
             
                    self
         
     | 
| 
       27 
27 
     | 
    
         
             
                  end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                  def  
     | 
| 
       30 
     | 
    
         
            -
                     
     | 
| 
      
 29 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 30 
     | 
    
         
            +
                    description = "#{association_message} #{expected}"
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    [description, submatchers.map(&:description)].flatten.join(' ')
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  def failure_message
         
     | 
| 
      
 36 
     | 
    
         
            +
                    "Expected #{expectation}"
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  def failure_message_when_negated
         
     | 
| 
      
 40 
     | 
    
         
            +
                    "Did not expect #{expectation}"
         
     | 
| 
       31 
41 
     | 
    
         
             
                  end
         
     | 
| 
       32 
42 
     | 
    
         | 
| 
       33 
43 
     | 
    
         
             
                  private
         
     | 
| 
       34 
44 
     | 
    
         | 
| 
       35 
45 
     | 
    
         
             
                  attr_reader :relationship_matcher, :relationship_type
         
     | 
| 
       36 
46 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                  def  
     | 
| 
       38 
     | 
    
         
            -
                    " 
     | 
| 
      
 47 
     | 
    
         
            +
                  def expectation
         
     | 
| 
      
 48 
     | 
    
         
            +
                    expectation = "#{serializer_name} to #{association_message} #{expected}"
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                    submatchers_expectations = failing_submatchers.map do |submatcher|
         
     | 
| 
      
 51 
     | 
    
         
            +
                      "(#{submatcher.expectation})"
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end.compact.join(", ")
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    [expectation, submatchers_expectations].reject(&:nil?).reject(&:empty?).join(" ")
         
     | 
| 
       39 
55 
     | 
    
         
             
                  end
         
     | 
| 
       40 
56 
     | 
    
         | 
| 
       41 
57 
     | 
    
         
             
                  def relationship_matches?
         
     | 
| 
         @@ -47,7 +63,7 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       47 
63 
     | 
    
         
             
                  end
         
     | 
| 
       48 
64 
     | 
    
         | 
| 
       49 
65 
     | 
    
         
             
                  def association_message
         
     | 
| 
       50 
     | 
    
         
            -
                    relationship_matcher.to_s.split( 
     | 
| 
      
 66 
     | 
    
         
            +
                    relationship_matcher.to_s.split("_").join(" ")
         
     | 
| 
       51 
67 
     | 
    
         
             
                  end
         
     | 
| 
       52 
68 
     | 
    
         | 
| 
       53 
69 
     | 
    
         
             
                  def actual
         
     | 
| 
         @@ -18,18 +18,18 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       18 
18 
     | 
    
         
             
                      actual == expected
         
     | 
| 
       19 
19 
     | 
    
         
             
                    end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                    def  
     | 
| 
       22 
     | 
    
         
            -
                       
     | 
| 
      
 21 
     | 
    
         
            +
                    def description
         
     | 
| 
      
 22 
     | 
    
         
            +
                      "with serializer #{expected}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    def expectation
         
     | 
| 
      
 26 
     | 
    
         
            +
                      [ "with serializer #{expected}", actual_message ].compact.join(", ")
         
     | 
| 
       23 
27 
     | 
    
         
             
                    end
         
     | 
| 
       24 
28 
     | 
    
         | 
| 
       25 
29 
     | 
    
         
             
                    private
         
     | 
| 
       26 
30 
     | 
    
         | 
| 
       27 
31 
     | 
    
         
             
                    attr_reader :relationship_target
         
     | 
| 
       28 
32 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                    def expected_message
         
     | 
| 
       30 
     | 
    
         
            -
                      "expected #{serializer_name} to use #{expected} as serializer for #{relationship_target}"
         
     | 
| 
       31 
     | 
    
         
            -
                    end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
33 
     | 
    
         
             
                    def actual_message
         
     | 
| 
       34 
34 
     | 
    
         
             
                      actual ? "got #{actual} instead" : nil
         
     | 
| 
       35 
35 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -13,27 +13,17 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       13 
13 
     | 
    
         
             
                  end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                  def failure_message
         
     | 
| 
       16 
     | 
    
         
            -
                     
     | 
| 
      
 16 
     | 
    
         
            +
                    raise NotImplementedError
         
     | 
| 
       17 
17 
     | 
    
         
             
                  end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                  def failure_message_when_negated
         
     | 
| 
       20 
     | 
    
         
            -
                     
     | 
| 
       21 
     | 
    
         
            -
                      .compact
         
     | 
| 
       22 
     | 
    
         
            -
                      .join("\n")
         
     | 
| 
      
 20 
     | 
    
         
            +
                    raise NotImplementedError
         
     | 
| 
       23 
21 
     | 
    
         
             
                  end
         
     | 
| 
       24 
22 
     | 
    
         | 
| 
       25 
23 
     | 
    
         
             
                  protected
         
     | 
| 
       26 
24 
     | 
    
         | 
| 
       27 
25 
     | 
    
         
             
                  attr_reader :expected, :serializer_instance, :submatchers
         
     | 
| 
       28 
26 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                  def main_failure_message
         
     | 
| 
       30 
     | 
    
         
            -
                    raise NotImplementedError
         
     | 
| 
       31 
     | 
    
         
            -
                  end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                  def main_failure_message_when_negated
         
     | 
| 
       34 
     | 
    
         
            -
                    raise NotImplementedError
         
     | 
| 
       35 
     | 
    
         
            -
                  end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
27 
     | 
    
         
             
                  def add_submatcher(submatcher)
         
     | 
| 
       38 
28 
     | 
    
         
             
                    submatchers << submatcher
         
     | 
| 
       39 
29 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -50,16 +40,6 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       50 
40 
     | 
    
         
             
                    serializer_instance.class.name
         
     | 
| 
       51 
41 
     | 
    
         
             
                  end
         
     | 
| 
       52 
42 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                  private
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                  def submatcher_failure_messages
         
     | 
| 
       56 
     | 
    
         
            -
                    failing_submatchers.map(&:failure_message)
         
     | 
| 
       57 
     | 
    
         
            -
                  end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                  def submatcher_failure_messages_when_negated
         
     | 
| 
       60 
     | 
    
         
            -
                    failing_submatchers.map(&:failure_message_when_negated)
         
     | 
| 
       61 
     | 
    
         
            -
                  end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
43 
     | 
    
         
             
                  def failing_submatchers
         
     | 
| 
       64 
44 
     | 
    
         
             
                    @failing_submatchers ||= submatchers.select do |submatcher|
         
     | 
| 
       65 
45 
     | 
    
         
             
                      !submatcher.matches?(serializer_instance)
         
     | 
| 
         @@ -17,8 +17,16 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    association_matcher.serializer(value)
         
     | 
| 
       18 
18 
     | 
    
         
             
                  end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                  def  
     | 
| 
       21 
     | 
    
         
            -
                    association_matcher. 
     | 
| 
      
 20 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 21 
     | 
    
         
            +
                    association_matcher.description
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def failure_message
         
     | 
| 
      
 25 
     | 
    
         
            +
                    association_matcher.failure_message
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def failure_message_when_negated
         
     | 
| 
      
 29 
     | 
    
         
            +
                    association_matcher.failure_message_when_negated
         
     | 
| 
       22 
30 
     | 
    
         
             
                  end
         
     | 
| 
       23 
31 
     | 
    
         | 
| 
       24 
32 
     | 
    
         
             
                  private
         
     | 
| 
         @@ -19,17 +19,35 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                  def as_nil
         
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
      
 22 
     | 
    
         
            +
                    as(nil)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 26 
     | 
    
         
            +
                    description = "have attribute #{expected}"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    [description, submatchers.map(&:description)].flatten.join(' ')
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def failure_message
         
     | 
| 
      
 32 
     | 
    
         
            +
                    "Expected #{expectation}."
         
     | 
| 
       25 
33 
     | 
    
         
             
                  end
         
     | 
| 
       26 
34 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                  def  
     | 
| 
       28 
     | 
    
         
            -
                    " 
     | 
| 
      
 35 
     | 
    
         
            +
                  def failure_message_when_negated
         
     | 
| 
      
 36 
     | 
    
         
            +
                    "Did not expect #{expectation}."
         
     | 
| 
       29 
37 
     | 
    
         
             
                  end
         
     | 
| 
       30 
38 
     | 
    
         | 
| 
       31 
39 
     | 
    
         
             
                  private
         
     | 
| 
       32 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
                  def expectation
         
     | 
| 
      
 42 
     | 
    
         
            +
                    expectation = "#{serializer_name} to have attribute #{expected}"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    submatchers_expectations = failing_submatchers.map do |submatcher|
         
     | 
| 
      
 45 
     | 
    
         
            +
                      "(#{submatcher.expectation})"
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end.compact.join(", ")
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    [expectation, submatchers_expectations].reject(&:nil?).reject(&:empty?).join(" ")
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
       33 
51 
     | 
    
         
             
                  def attributes
         
     | 
| 
       34 
52 
     | 
    
         
             
                    @attributes ||= serializer_instance.class.try(:attributes_to_serialize) || {}
         
     | 
| 
       35 
53 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -18,20 +18,30 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       18 
18 
     | 
    
         
             
                      actual == expected
         
     | 
| 
       19 
19 
     | 
    
         
             
                    end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                    def  
     | 
| 
       22 
     | 
    
         
            -
                       
     | 
| 
      
 21 
     | 
    
         
            +
                    def description
         
     | 
| 
      
 22 
     | 
    
         
            +
                      "as #{expected_to_string}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    def expectation
         
     | 
| 
      
 26 
     | 
    
         
            +
                      [ "as #{expected_to_string}", actual_message ].compact.join(", ")
         
     | 
| 
       23 
27 
     | 
    
         
             
                    end
         
     | 
| 
       24 
28 
     | 
    
         | 
| 
       25 
29 
     | 
    
         
             
                    private
         
     | 
| 
       26 
30 
     | 
    
         | 
| 
       27 
31 
     | 
    
         
             
                    attr_reader :attribute
         
     | 
| 
       28 
32 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                    def  
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
      
 33 
     | 
    
         
            +
                    def expected_to_string
         
     | 
| 
      
 34 
     | 
    
         
            +
                      value_to_string(expected)
         
     | 
| 
       31 
35 
     | 
    
         
             
                    end
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
       33 
37 
     | 
    
         
             
                    def actual_message
         
     | 
| 
       34 
     | 
    
         
            -
                      "got #{actual 
     | 
| 
      
 38 
     | 
    
         
            +
                      "got #{value_to_string(actual)} instead" if attributes.has_key?(attribute)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                    def value_to_string(value)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      return 'nil' if value.nil?
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                      value.to_s
         
     | 
| 
       35 
45 
     | 
    
         
             
                    end
         
     | 
| 
       36 
46 
     | 
    
         | 
| 
       37 
47 
     | 
    
         
             
                    def actual
         
     | 
| 
         @@ -19,17 +19,35 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                  def as_nil
         
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
      
 22 
     | 
    
         
            +
                    as(nil)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 26 
     | 
    
         
            +
                    description = "have link #{expected}"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    [description, submatchers.map(&:description)].flatten.join(' ')
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def failure_message
         
     | 
| 
      
 32 
     | 
    
         
            +
                    "Expected #{expectation}."
         
     | 
| 
       25 
33 
     | 
    
         
             
                  end
         
     | 
| 
       26 
34 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                  def  
     | 
| 
       28 
     | 
    
         
            -
                    " 
     | 
| 
      
 35 
     | 
    
         
            +
                  def failure_message_when_negated
         
     | 
| 
      
 36 
     | 
    
         
            +
                    "Did not expect #{expectation}."
         
     | 
| 
       29 
37 
     | 
    
         
             
                  end
         
     | 
| 
       30 
38 
     | 
    
         | 
| 
       31 
39 
     | 
    
         
             
                  private
         
     | 
| 
       32 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
                  def expectation
         
     | 
| 
      
 42 
     | 
    
         
            +
                    expectation = "#{serializer_name} to have link #{expected}"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    submatchers_expectations = failing_submatchers.map do |submatcher|
         
     | 
| 
      
 45 
     | 
    
         
            +
                      "(#{submatcher.expectation})"
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end.compact.join(", ")
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    [expectation, submatchers_expectations].reject(&:nil?).reject(&:empty?).join(" ")
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
       33 
51 
     | 
    
         
             
                  def has_link?
         
     | 
| 
       34 
52 
     | 
    
         
             
                    links.has_key?(expected)
         
     | 
| 
       35 
53 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -18,20 +18,30 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       18 
18 
     | 
    
         
             
                      actual == expected
         
     | 
| 
       19 
19 
     | 
    
         
             
                    end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                    def  
     | 
| 
       22 
     | 
    
         
            -
                       
     | 
| 
      
 21 
     | 
    
         
            +
                    def description
         
     | 
| 
      
 22 
     | 
    
         
            +
                      "as #{expected_to_string}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    def expectation
         
     | 
| 
      
 26 
     | 
    
         
            +
                      [ "as #{expected_to_string}", actual_message ].compact.join(", ")
         
     | 
| 
       23 
27 
     | 
    
         
             
                    end
         
     | 
| 
       24 
28 
     | 
    
         | 
| 
       25 
29 
     | 
    
         
             
                    private
         
     | 
| 
       26 
30 
     | 
    
         | 
| 
       27 
31 
     | 
    
         
             
                    attr_reader :link
         
     | 
| 
       28 
32 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                    def  
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
      
 33 
     | 
    
         
            +
                    def expected_to_string
         
     | 
| 
      
 34 
     | 
    
         
            +
                      value_to_string(expected)
         
     | 
| 
       31 
35 
     | 
    
         
             
                    end
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
       33 
37 
     | 
    
         
             
                    def actual_message
         
     | 
| 
       34 
     | 
    
         
            -
                      "got #{actual 
     | 
| 
      
 38 
     | 
    
         
            +
                      "got #{value_to_string(actual)} instead" if links.has_key?(link)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                    def value_to_string(value)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      return 'nil' if value.nil?
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                      value.to_s
         
     | 
| 
       35 
45 
     | 
    
         
             
                    end
         
     | 
| 
       36 
46 
     | 
    
         | 
| 
       37 
47 
     | 
    
         
             
                    def actual
         
     | 
| 
         @@ -17,8 +17,16 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    association_matcher.serializer(value)
         
     | 
| 
       18 
18 
     | 
    
         
             
                  end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                  def  
     | 
| 
       21 
     | 
    
         
            -
                    association_matcher. 
     | 
| 
      
 20 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 21 
     | 
    
         
            +
                    association_matcher.description
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def failure_message
         
     | 
| 
      
 25 
     | 
    
         
            +
                    association_matcher.failure_message
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def failure_message_when_negated
         
     | 
| 
      
 29 
     | 
    
         
            +
                    association_matcher.failure_message_when_negated
         
     | 
| 
       22 
30 
     | 
    
         
             
                  end
         
     | 
| 
       23 
31 
     | 
    
         | 
| 
       24 
32 
     | 
    
         
             
                  private
         
     | 
| 
         @@ -19,17 +19,35 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                  def as_nil
         
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
      
 22 
     | 
    
         
            +
                    as(nil)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 26 
     | 
    
         
            +
                    description = "serialize meta #{expected}"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    [description, submatchers.map(&:description)].flatten.join(' ')
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def failure_message
         
     | 
| 
      
 32 
     | 
    
         
            +
                    "Expected #{expectation}."
         
     | 
| 
       25 
33 
     | 
    
         
             
                  end
         
     | 
| 
       26 
34 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                  def  
     | 
| 
       28 
     | 
    
         
            -
                    " 
     | 
| 
      
 35 
     | 
    
         
            +
                  def failure_message_when_negated
         
     | 
| 
      
 36 
     | 
    
         
            +
                    "Did not expect #{expectation}."
         
     | 
| 
       29 
37 
     | 
    
         
             
                  end
         
     | 
| 
       30 
38 
     | 
    
         | 
| 
       31 
39 
     | 
    
         
             
                  private
         
     | 
| 
       32 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
                  def expectation
         
     | 
| 
      
 42 
     | 
    
         
            +
                    expectation = "#{serializer_name} to serialize meta #{expected}"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    submatchers_expectations = failing_submatchers.map do |submatcher|
         
     | 
| 
      
 45 
     | 
    
         
            +
                      "(#{submatcher.expectation})"
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end.compact.join(", ")
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    [expectation, submatchers_expectations].reject(&:nil?).reject(&:empty?).join(" ")
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
       33 
51 
     | 
    
         
             
                  def metas
         
     | 
| 
       34 
52 
     | 
    
         
             
                    @metas ||= serializable_hash.dig(:data, :meta) || {}
         
     | 
| 
       35 
53 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -18,22 +18,33 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       18 
18 
     | 
    
         
             
                      actual == expected
         
     | 
| 
       19 
19 
     | 
    
         
             
                    end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                    def  
     | 
| 
       22 
     | 
    
         
            -
                       
     | 
| 
      
 21 
     | 
    
         
            +
                    def description
         
     | 
| 
      
 22 
     | 
    
         
            +
                      "as #{expected_to_string}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    def expectation
         
     | 
| 
      
 26 
     | 
    
         
            +
                      [ "as #{expected_to_string}", actual_message ].compact.join(", ")
         
     | 
| 
       23 
27 
     | 
    
         
             
                    end
         
     | 
| 
       24 
28 
     | 
    
         | 
| 
       25 
29 
     | 
    
         
             
                    private
         
     | 
| 
       26 
30 
     | 
    
         | 
| 
       27 
31 
     | 
    
         
             
                    attr_reader :meta
         
     | 
| 
       28 
32 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                    def  
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
      
 33 
     | 
    
         
            +
                    def expected_to_string
         
     | 
| 
      
 34 
     | 
    
         
            +
                      value_to_string(expected)
         
     | 
| 
       31 
35 
     | 
    
         
             
                    end
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
       33 
37 
     | 
    
         
             
                    def actual_message
         
     | 
| 
       34 
38 
     | 
    
         
             
                      "got #{actual.nil? ? 'nil' : actual} instead" if metas.has_key?(meta)
         
     | 
| 
       35 
39 
     | 
    
         
             
                    end
         
     | 
| 
       36 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
                    def value_to_string(value)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      return 'nil' if value.nil?
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                      value.to_s
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
       37 
48 
     | 
    
         
             
                    def actual
         
     | 
| 
       38 
49 
     | 
    
         
             
                      metas[meta]
         
     | 
| 
       39 
50 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -17,8 +17,16 @@ module RSpecJSONAPISerializer 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    association_matcher.serializer(value)
         
     | 
| 
       18 
18 
     | 
    
         
             
                  end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                  def  
     | 
| 
       21 
     | 
    
         
            -
                    association_matcher. 
     | 
| 
      
 20 
     | 
    
         
            +
                  def description
         
     | 
| 
      
 21 
     | 
    
         
            +
                    association_matcher.description
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def failure_message
         
     | 
| 
      
 25 
     | 
    
         
            +
                    association_matcher.failure_message
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def failure_message_when_negated
         
     | 
| 
      
 29 
     | 
    
         
            +
                    association_matcher.failure_message_when_negated
         
     | 
| 
       22 
30 
     | 
    
         
             
                  end
         
     | 
| 
       23 
31 
     | 
    
         | 
| 
       24 
32 
     | 
    
         
             
                  private
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rspec_jsonapi_serializer
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Mateus Cruz
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-05-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: jsonapi-serializer
         
     | 
| 
         @@ -24,7 +24,7 @@ dependencies: 
     | 
|
| 
       24 
24 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '2.0'
         
     | 
| 
       27 
     | 
    
         
            -
            description: 
     | 
| 
      
 27 
     | 
    
         
            +
            description:
         
     | 
| 
       28 
28 
     | 
    
         
             
            email:
         
     | 
| 
       29 
29 
     | 
    
         
             
            - mateus@intricately.com
         
     | 
| 
       30 
30 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -56,7 +56,7 @@ metadata: 
     | 
|
| 
       56 
56 
     | 
    
         
             
              homepage_uri: https://github.com/teamintricately/rspec_jsonapi_serializer
         
     | 
| 
       57 
57 
     | 
    
         
             
              source_code_uri: https://github.com/teamintricately/rspec_jsonapi_serializer
         
     | 
| 
       58 
58 
     | 
    
         
             
              changelog_uri: https://github.com/teamintricately/rspec_jsonapi_serializer/blob/main/CHANGELOG.md
         
     | 
| 
       59 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 59 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       60 
60 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       61 
61 
     | 
    
         
             
            require_paths:
         
     | 
| 
       62 
62 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -71,8 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       71 
71 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       72 
72 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       73 
73 
     | 
    
         
             
            requirements: []
         
     | 
| 
       74 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       75 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 74 
     | 
    
         
            +
            rubygems_version: 3.3.7
         
     | 
| 
      
 75 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       76 
76 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       77 
77 
     | 
    
         
             
            summary: RSpec matchers for jsonapi-serializer.
         
     | 
| 
       78 
78 
     | 
    
         
             
            test_files: []
         
     |