rspec-protobuf 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +48 -0
- data/lib/rspec/protobuf/refinements.rb +19 -2
- data/lib/rspec/protobuf/version.rb +1 -1
- data/lib/rspec/protobuf.rb +1 -1
- data/rspec-protobuf.gemspec +2 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9715606ee55a551b67daf4f76770e03e02c39235df6391dabcfb4e652f66573b
|
4
|
+
data.tar.gz: d94dc7b32595629de99af8174117019af34916e3be13b8ac7c341c3ad1379462
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e20abb11a4f1f56bde4fcc953d492d57b79cb434696a0a4c7923fb818a7c021ef26a5b058b2af8df13bf2a6256518559e21b78f334d7db0073adb84317531bc
|
7
|
+
data.tar.gz: 170d177431f45d5e0e5584ac775f2480aa3975e64aaaf626248d2e4dd80f7eb22feaa3aed7a9a3159b176a23b573a53f31f168045487a669a8831c8e0ab65314
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-protobuf (0.2.1)
|
5
|
+
google-protobuf (>= 3)
|
6
|
+
rspec-expectations (>= 3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
byebug (11.1.3)
|
12
|
+
codecov (0.6.0)
|
13
|
+
simplecov (>= 0.15, < 0.22)
|
14
|
+
diff-lcs (1.5.0)
|
15
|
+
docile (1.4.0)
|
16
|
+
google-protobuf (3.21.12)
|
17
|
+
rspec (3.12.0)
|
18
|
+
rspec-core (~> 3.12.0)
|
19
|
+
rspec-expectations (~> 3.12.0)
|
20
|
+
rspec-mocks (~> 3.12.0)
|
21
|
+
rspec-core (3.12.0)
|
22
|
+
rspec-support (~> 3.12.0)
|
23
|
+
rspec-expectations (3.12.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.12.0)
|
26
|
+
rspec-mocks (3.12.1)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.12.0)
|
29
|
+
rspec-support (3.12.0)
|
30
|
+
simplecov (0.21.2)
|
31
|
+
docile (~> 1.1)
|
32
|
+
simplecov-html (~> 0.11)
|
33
|
+
simplecov_json_formatter (~> 0.1)
|
34
|
+
simplecov-html (0.12.3)
|
35
|
+
simplecov_json_formatter (0.1.4)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
byebug
|
42
|
+
codecov
|
43
|
+
rspec (>= 3)
|
44
|
+
rspec-protobuf!
|
45
|
+
simplecov
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.3.17
|
@@ -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
|
data/lib/rspec/protobuf.rb
CHANGED
data/rspec-protobuf.gemspec
CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = `git ls-files * ':!:spec'`.split("\n")
|
16
16
|
|
17
17
|
s.add_dependency "google-protobuf", ">= 3"
|
18
|
-
s.add_dependency "rspec", ">= 3"
|
18
|
+
s.add_dependency "rspec-expectations", ">= 3"
|
19
19
|
|
20
20
|
s.add_development_dependency "byebug"
|
21
21
|
s.add_development_dependency "codecov"
|
22
|
+
s.add_development_dependency "rspec", ">= 3"
|
22
23
|
s.add_development_dependency "simplecov"
|
23
24
|
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.2
|
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
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
28
|
+
name: rspec-expectations
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +102,7 @@ extra_rdoc_files: []
|
|
88
102
|
files:
|
89
103
|
- CHANGELOG.md
|
90
104
|
- Gemfile
|
105
|
+
- Gemfile.lock
|
91
106
|
- LICENSE.txt
|
92
107
|
- README.md
|
93
108
|
- lib/rspec-protobuf.rb
|