gruf-rspec 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d69cd78b329bf49a6fc236ff1a0efd167c171c5986140bfa5a4c9857762c3613
4
- data.tar.gz: d6263f0323ba55d06ba7ee55eff55f197153309478ad2f330b076e1e10503cb8
3
+ metadata.gz: fead8ef219ccbfd5f0bbb8f1f33c074d1d3bb9096edff7975689e5f250dd3d5b
4
+ data.tar.gz: c2b53d50821bbe478d0de586d8538097dedb286db75c2546b6254cc93598bd6e
5
5
  SHA512:
6
- metadata.gz: f3dd9ed14a1725bcf86a6e691f86a465073ecb65a0d04cc6e1813b0fe9f6b69c5e68057a6361774bd726860a00889c3d8694abc6dcf6a337fb9a9c3928e82830
7
- data.tar.gz: 460bc177f456c0f6c69f0dfd6a85d29d838956ecfdf49c4e75f73c2743f4976d1bb200968235112ebf648d71ee875985c5cce90052d20139fbe5d16c78a8cf01
6
+ metadata.gz: afd11a9b2f7dc98b1fad45ed7f392c388b9b9200420b23f29fd08e9325d07bfa855eaa996be91e6ed96c63eaf4ff40193cb5026effb36ea498ffaab88a60b280
7
+ data.tar.gz: fcac7c62fea2b5b20c533e277410bc222957dfea8a441408ffc36660e3d3c76a83389c01e7edaa7d09f9e79a911019e218a362144c38f0d60901cef9a5b8976f
data/CHANGELOG.md CHANGED
@@ -2,4 +2,10 @@ Changelog for the gruf-rspec gem.
2
2
 
3
3
  ### Pending release
4
4
 
5
+ ### 0.1.1
6
+
7
+ * Add be_a_successful_rpc matcher that matches on success and the appropriate response class
8
+
9
+ ### 0.1.0
10
+
5
11
  * Initial release
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # gruf-rspec
2
2
 
3
- [![Build Status](https://travis-ci.com/bigcommerce/gruf-rspec.svg?token=D3Cc4LCF9BgpUx4dpPpv&branch=master)](https://travis-ci.com/bigcommerce/gruf-rspec)
3
+ [![Build Status](https://travis-ci.com/bigcommerce/gruf-rspec.svg?token=D3Cc4LCF9BgpUx4dpPpv&branch=master)](https://travis-ci.com/bigcommerce/gruf-rspec) [![Gem Version](https://badge.fury.io/rb/gruf-rspec.svg)](https://badge.fury.io/rb/gruf-rspec) [![Documentation](https://inch-ci.org/github/bigcommerce/gruf-rspec.svg?branch=master)](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).
@@ -45,7 +45,7 @@ To test it, you'd create `spec/rpc/thing_controller_spec.rb`:
45
45
  ```ruby
46
46
  describe ThingController do
47
47
  describe '.get_thing' do
48
- let(:request_proto) { Rpc::GetThingResponse.new(id: rand(1..100)) }
48
+ let(:request_proto) { Rpc::GetThingRequest.new(id: rand(1..100)) }
49
49
 
50
50
  subject { run_rpc(:GetThing, request_proto) }
51
51
 
@@ -84,7 +84,7 @@ You can match against errors as well:
84
84
 
85
85
  ```ruby
86
86
  describe 'testing an error' do
87
- let(:request_proto) { Rpc::GetThingResponse.new(id: rand(1..100)) }
87
+ let(:request_proto) { Rpc::GetThingRequest.new(id: rand(1..100)) }
88
88
 
89
89
  subject { run_rpc(:GetThing, request_proto) }
90
90
 
data/lib/gruf/rspec.rb CHANGED
@@ -89,3 +89,15 @@ RSPEC_NAMESPACE::Matchers.define :raise_rpc_error do |expected_error_class|
89
89
  @error_matcher.error_message
90
90
  end
91
91
  end
92
+
93
+ RSPEC_NAMESPACE::Matchers.define :be_a_successful_rpc do |_|
94
+ match do |actual|
95
+ if !gruf_controller || actual.is_a?(GRPC::BadStatus) || actual.is_a?(GRPC::Core::CallError)
96
+ false
97
+ else
98
+ method_key = gruf_controller.request.method_key.to_s.camelcase.to_sym
99
+ expected_class = gruf_controller.class.bound_service.rpc_descs[method_key].output
100
+ expected_class == actual.class
101
+ end
102
+ end
103
+ end
@@ -15,6 +15,6 @@
15
15
  #
16
16
  module Gruf
17
17
  module Rspec
18
- VERSION = '0.1.0'.freeze
18
+ VERSION = '0.1.1'.freeze
19
19
  end
20
20
  end
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun McCormick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-26 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler