rspec-protobuf 0.2.0 → 0.2.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/CHANGELOG.md +3 -0
- data/lib/rspec/protobuf/refinements.rb +19 -2
- data/lib/rspec/protobuf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e02818bd754dbc93cdd721fd59642c53c442b50d23a351adb44eb0df3df146d9
|
4
|
+
data.tar.gz: e913a28c47e0280252f0eaf8a14f66ba16dcceb94de25d4cd227bc51ef40dbdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b8b8a507e7074155239ee294f122812c28d9575131f93a79315caa44b2b2aab26c931a696da3c17fb1a0491f7755e1a050067277fd24dbd20df206e1ee48da3
|
7
|
+
data.tar.gz: 65da298087c49ae41d64c8fa280418666a926abe904d89bb0045785bbed4070abd8a27be13e13e6842b5e706cadd89cd2719bcfb0c5c198a2ec1c24a2d3eb2c6
|
data/CHANGELOG.md
CHANGED
@@ -11,9 +11,18 @@ module RSpec
|
|
11
11
|
# ensure all enumerated attributes are present
|
12
12
|
return false unless expected_attrs.keys.all? { |attr| respond_to?(attr) }
|
13
13
|
|
14
|
+
fields = {}
|
15
|
+
self.class.descriptor.each { |f| fields[f.name.to_sym] = f }
|
16
|
+
|
14
17
|
# check expected attribute matches
|
15
18
|
expected_attrs.all? do |expected_attr, expected_value|
|
16
|
-
|
19
|
+
field = fields[expected_attr]
|
20
|
+
actual_value = field.get(self)
|
21
|
+
|
22
|
+
# convert enum to int value to match input type
|
23
|
+
if field.type == :enum && expected_value.is_a?(Integer)
|
24
|
+
actual_value = field.subtype.lookup_name(actual_value)
|
25
|
+
end
|
17
26
|
|
18
27
|
matches = expected_value === actual_value
|
19
28
|
|
@@ -41,7 +50,15 @@ module RSpec
|
|
41
50
|
if actual_value.is_a?(Google::Protobuf::MessageExts) && expected_value.is_a?(Hash)
|
42
51
|
actual_value.match?(**expected_value)
|
43
52
|
else
|
44
|
-
|
53
|
+
# fall back to default value
|
54
|
+
expected_value = field.default unless attrs.key?(field.name.to_sym)
|
55
|
+
|
56
|
+
# convert enum to int value to match input type
|
57
|
+
if field.type == :enum && expected_value.is_a?(Integer)
|
58
|
+
actual_value = field.subtype.lookup_name(actual_value)
|
59
|
+
end
|
60
|
+
|
61
|
+
expected_value === actual_value
|
45
62
|
end
|
46
63
|
end
|
47
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pepper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|