rspec_jsonapi_serializer 1.2.0 → 1.3.0
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 +7 -0
- data/lib/rspec_jsonapi_serializer/matchers/association_matchers/object_method_name_matcher.rb +47 -0
- data/lib/rspec_jsonapi_serializer/matchers/belong_to_matcher.rb +4 -0
- data/lib/rspec_jsonapi_serializer/matchers/have_many_matcher.rb +4 -0
- data/lib/rspec_jsonapi_serializer/matchers/have_one_matcher.rb +4 -0
- data/lib/rspec_jsonapi_serializer/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a01005a800b62bc1790bef3c0b41d7f39528016cbc3f44255100d60c06f6e3f7
|
4
|
+
data.tar.gz: 6870f0d87b139a4e50bedabc2af25faae9a9aa10918ee20cf7a31947b57ecb3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3de4e1e8b9253c30fd625113d0633e70a175546c071c413164af646fceb3785bcd1bb0c310e47f0b91162f48d0a7c989807cc32e13754b4376d89ecdebb195d
|
7
|
+
data.tar.gz: b65538587e22e77df17ef8acaca5694ca9212b7827e9e8ec35dcf4583b860f6ca287396b92bdb01a88aa623f7fabe520c76ff95036c8efb22351f8453e74c771
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "rspec_jsonapi_serializer/matchers/base"
|
4
4
|
require "rspec_jsonapi_serializer/matchers/association_matchers/serializer_matcher"
|
5
5
|
require "rspec_jsonapi_serializer/matchers/association_matchers/id_method_name_matcher"
|
6
|
+
require "rspec_jsonapi_serializer/matchers/association_matchers/object_method_name_matcher"
|
6
7
|
require "rspec_jsonapi_serializer/metadata/relationships"
|
7
8
|
|
8
9
|
module RSpecJSONAPISerializer
|
@@ -33,6 +34,12 @@ module RSpecJSONAPISerializer
|
|
33
34
|
self
|
34
35
|
end
|
35
36
|
|
37
|
+
def object_method_name(value)
|
38
|
+
add_submatcher AssociationMatchers::ObjectMethodNameMatcher.new(value, expected)
|
39
|
+
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
36
43
|
def main_failure_message
|
37
44
|
[expected_message, actual_message].compact.join(", ")
|
38
45
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rspec_jsonapi_serializer/metadata/relationships"
|
4
|
+
|
5
|
+
module RSpecJSONAPISerializer
|
6
|
+
module Matchers
|
7
|
+
module AssociationMatchers
|
8
|
+
class ObjectMethodNameMatcher < Base
|
9
|
+
def initialize(value, relationship_target)
|
10
|
+
super(value)
|
11
|
+
|
12
|
+
@relationship_target = relationship_target
|
13
|
+
end
|
14
|
+
|
15
|
+
def matches?(serializer_instance)
|
16
|
+
@serializer_instance = serializer_instance
|
17
|
+
|
18
|
+
actual == expected
|
19
|
+
end
|
20
|
+
|
21
|
+
def main_failure_message
|
22
|
+
[expected_message, actual_message].compact.join(", ")
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :relationship_target
|
28
|
+
|
29
|
+
def expected_message
|
30
|
+
"expected #{serializer_name} to use #{expected} as object_method_name for #{relationship_target}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def actual_message
|
34
|
+
actual ? "got #{actual} instead" : nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def actual
|
38
|
+
metadata.relationship(relationship_target).object_method_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def metadata
|
42
|
+
Metadata::Relationships.new(serializer_instance)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateus Cruz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializer
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/rspec_jsonapi_serializer/matchers.rb
|
36
36
|
- lib/rspec_jsonapi_serializer/matchers/association_matcher.rb
|
37
37
|
- lib/rspec_jsonapi_serializer/matchers/association_matchers/id_method_name_matcher.rb
|
38
|
+
- lib/rspec_jsonapi_serializer/matchers/association_matchers/object_method_name_matcher.rb
|
38
39
|
- lib/rspec_jsonapi_serializer/matchers/association_matchers/serializer_matcher.rb
|
39
40
|
- lib/rspec_jsonapi_serializer/matchers/base.rb
|
40
41
|
- lib/rspec_jsonapi_serializer/matchers/belong_to_matcher.rb
|
@@ -50,13 +51,13 @@ files:
|
|
50
51
|
- lib/rspec_jsonapi_serializer/matchers/have_type_matcher.rb
|
51
52
|
- lib/rspec_jsonapi_serializer/metadata/relationships.rb
|
52
53
|
- lib/rspec_jsonapi_serializer/version.rb
|
53
|
-
homepage: https://github.com/
|
54
|
+
homepage: https://github.com/mateuscruz/rspec_jsonapi_serializer
|
54
55
|
licenses:
|
55
56
|
- MIT
|
56
57
|
metadata:
|
57
|
-
homepage_uri: https://github.com/
|
58
|
-
source_code_uri: https://github.com/
|
59
|
-
changelog_uri: https://github.com/
|
58
|
+
homepage_uri: https://github.com/mateuscruz/rspec_jsonapi_serializer
|
59
|
+
source_code_uri: https://github.com/mateuscruz/rspec_jsonapi_serializer
|
60
|
+
changelog_uri: https://github.com/mateuscruz/rspec_jsonapi_serializer/blob/main/CHANGELOG.md
|
60
61
|
post_install_message:
|
61
62
|
rdoc_options: []
|
62
63
|
require_paths:
|
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: '0'
|
74
75
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.3.7
|
76
77
|
signing_key:
|
77
78
|
specification_version: 4
|
78
79
|
summary: RSpec matchers for jsonapi-serializer.
|