gruf-rspec 0.1.2 → 0.1.3
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 +4 -0
- data/README.md +9 -5
- data/lib/gruf/rspec.rb +2 -2
- data/lib/gruf/rspec/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8d0d67cd2d8e98f3df81aa980be153313ccaaa01381d603f34dac2b7acdd9c9
|
4
|
+
data.tar.gz: 9efd36045c83aeaed1815b463afa2c10b7bb14190604f1685cac6e0a89c16756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 533a16373dfb91ccc3587194064a0be3c5108513683957f1be0d918fb6eb7d7785a4a2c2e31c1d0cba5595ccf82abf62b2df5b1c1c84f62c52f3d72fd8de7f10
|
7
|
+
data.tar.gz: 1da2b6434529984d65bd04a3faf461bd5774a5719cf38d3bdd6b4be26864fbd995d5e387d4c07d5f5c2c4affa3f46bcd9eb6ee9b545c77c5b85e78e0129fc2ca
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# gruf-rspec
|
2
2
|
|
3
|
-
[](https://circleci.com/gh/bigcommerce/gruf-rspec/tree/master) [](https://badge.fury.io/rb/gruf-rspec) [](https://inch-ci.org/github/bigcommerce/gruf-rspec?branch=master)
|
4
4
|
|
5
5
|
Assistance helpers and custom type for easy testing [Gruf](https://github.com/bigcommerce/gruf) controllers with
|
6
6
|
[RSpec](https://github.com/rspec/rspec).
|
@@ -22,7 +22,8 @@ Note that this gem requires at least Gruf 2.5.1+ and RSpec 3.8+.
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
* Add a test for a Gruf controller in `spec/rpc`
|
25
|
-
* Run the `run_rpc` method with
|
25
|
+
* Run the `run_rpc` method with three args: The gRPC method name, the request object
|
26
|
+
and the active_call_options. The third argument is optional.
|
26
27
|
* Validate the response
|
27
28
|
|
28
29
|
## Example
|
@@ -46,9 +47,12 @@ To test it, you'd create `spec/rpc/thing_controller_spec.rb`:
|
|
46
47
|
describe ThingController do
|
47
48
|
describe '.get_thing' do
|
48
49
|
let(:request_proto) { Rpc::GetThingRequest.new(id: rand(1..100)) }
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
let(:metadata) {
|
51
|
+
{ 'user_id' => 'axj42i' }
|
52
|
+
}
|
53
|
+
|
54
|
+
subject { run_rpc(:GetThing, request_proto, active_call_options: { metadata: metadata }) }
|
55
|
+
|
52
56
|
it 'will return the thing' do
|
53
57
|
expect(subject).to be_a(Rpc::GetThingResponse)
|
54
58
|
expect(subject.id).to eq request_proto.id
|
data/lib/gruf/rspec.rb
CHANGED
@@ -45,12 +45,12 @@ GRUF_RSPEC_RUNNER.configure do |config|
|
|
45
45
|
end
|
46
46
|
|
47
47
|
config.before(:each, type: :gruf_controller) do
|
48
|
-
define_singleton_method :run_rpc do |method_name, request, &block|
|
48
|
+
define_singleton_method :run_rpc do |method_name, request, active_call_options: {}, &block|
|
49
49
|
@gruf_controller = described_class.new(
|
50
50
|
method_key: method_name.to_s.underscore.to_sym,
|
51
51
|
service: grpc_bound_service,
|
52
52
|
rpc_desc: grpc_bound_service.rpc_descs[method_name.to_sym],
|
53
|
-
active_call: grpc_active_call,
|
53
|
+
active_call: grpc_active_call(active_call_options),
|
54
54
|
message: request
|
55
55
|
)
|
56
56
|
resp = @gruf_controller.call(@gruf_controller.request.method_key)
|
data/lib/gruf/rspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gruf-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
rubygems_version: 3.0.
|
127
|
+
rubygems_version: 3.0.6
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: RSpec assistance library for gruf
|