rspec_jsonapi_serializer 1.2.1 → 1.3.1
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 +12 -5
- 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 +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3617cae7caacd8695894c6395f675128d6bca1c995b66a2c5710e2f30de821d5
|
4
|
+
data.tar.gz: f8a012ed9e4e291dfdafeded91f460ce1273c64bdf0e6fc18b7c3aa56c7dc6e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4464405e91954ab43d68dbc886e8c8ab13f646ebad343ec95879ace14ef4a4b42515f7f9b8d035b84d4b0bd92be4b297188427f647d626e18afb101353cc3cfb
|
7
|
+
data.tar.gz: 6b071952ee12ad8621d8724d606c9e19b3ff049104f3b8d83b72dddd29055dfcc4276661f7f914763ee3d6c28632bcf3d71138af556d41a8228b187e07f294da
|
@@ -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 description
|
37
44
|
description = "#{association_message} #{expected}"
|
38
45
|
|
@@ -62,17 +69,17 @@ module RSpecJSONAPISerializer
|
|
62
69
|
end
|
63
70
|
|
64
71
|
def relationship_matches?
|
65
|
-
actual.present? &&
|
66
|
-
end
|
67
|
-
|
68
|
-
def actual_message
|
69
|
-
actual ? "got :#{actual.relationship_type} instead" : nil
|
72
|
+
actual.present? && actual_relationship_type == relationship_type
|
70
73
|
end
|
71
74
|
|
72
75
|
def association_message
|
73
76
|
relationship_matcher.to_s.split("_").join(" ")
|
74
77
|
end
|
75
78
|
|
79
|
+
def actual_relationship_type
|
80
|
+
actual.relationship_type
|
81
|
+
end
|
82
|
+
|
76
83
|
def actual
|
77
84
|
metadata.relationship(expected)
|
78
85
|
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 description
|
22
|
+
"with object method name #{expected}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def expectation
|
26
|
+
[ "with object method name #{expected}", actual_message ].compact.join(", ")
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :relationship_target
|
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,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateus Cruz
|
@@ -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:
|