my_api_client 0.6.0 → 0.6.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: ad19788202ac1ee6711537e81d0ab8d459918a9660d85bced28ae051dbf06d23
4
- data.tar.gz: f36355f04e35e09473a3d4fdc6be1bb46bbd3b39d99d18b942d41891d581808a
3
+ metadata.gz: 93698a943856cab100913566c3dd718662d6c25a3f332add330d28d9071107db
4
+ data.tar.gz: 2c642b721e322c51a34c7fcb90accdb58ab6e73587a9b61b9b34cfd9041087ae
5
5
  SHA512:
6
- metadata.gz: 856baa51b7ee09c7178b6e3c3145ff313908b1790f4f051a19a987e645f9f9b4c4de8a2e2e0cd76d1cb9dac9dbabf210b90ff7dd8d78f4f1a1225cedb9f22628
7
- data.tar.gz: 984dc3fb7a188b11e454eff1c92086e58d7346498aa9f8333aa7c429896c695d708e19b34f3b96a98311e1e9539c5d4e0975d0b71d2d52bd673a5eb01c9b3ca7
6
+ metadata.gz: 4a884a59d5a3cc8b697d709f556b95152431958d51d0445803891dd0b0515eb142a2082f516bca321d9ada72b84b7c9f8924e37f813b1be01fa30a0e797b4e20
7
+ data.tar.gz: 752f41008a25167523950b3d4056e747755fa0d147f0981f2ac871d958c8dd03ad36295c9240d6cc6958a7266140c6447723398ec5aeb6f4401a969c329a68d1
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-05-30 23:31:07 +0000 using RuboCop version 0.71.0.
3
+ # on 2019-06-25 23:31:06 +0000 using RuboCop version 0.72.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (0.6.0)
4
+ my_api_client (0.6.1)
5
5
  activesupport (>= 4.2.0)
6
6
  jsonpath
7
7
  sawyer
@@ -54,14 +54,14 @@ GEM
54
54
  pry-byebug (3.7.0)
55
55
  byebug (~> 11.0)
56
56
  pry (~> 0.10)
57
- public_suffix (3.1.0)
57
+ public_suffix (3.1.1)
58
58
  rainbow (3.0.0)
59
59
  rake (10.5.0)
60
60
  rspec (3.8.0)
61
61
  rspec-core (~> 3.8.0)
62
62
  rspec-expectations (~> 3.8.0)
63
63
  rspec-mocks (~> 3.8.0)
64
- rspec-core (3.8.1)
64
+ rspec-core (3.8.2)
65
65
  rspec-support (~> 3.8.0)
66
66
  rspec-expectations (3.8.4)
67
67
  diff-lcs (>= 1.2.0, < 2.0)
@@ -88,7 +88,7 @@ GEM
88
88
  sawyer (0.8.2)
89
89
  addressable (>= 2.3.5)
90
90
  faraday (> 0.8, < 2.0)
91
- simplecov (0.16.1)
91
+ simplecov (0.17.0)
92
92
  docile (~> 1.1)
93
93
  json (>= 1.8, < 3)
94
94
  simplecov-html (~> 0.10.0)
@@ -102,7 +102,7 @@ GEM
102
102
  addressable (>= 2.3.6)
103
103
  crack (>= 0.3.2)
104
104
  hashdiff (>= 0.4.0, < 2.0.0)
105
- yard (0.9.19)
105
+ yard (0.9.20)
106
106
 
107
107
  PLATFORMS
108
108
  ruby
data/README.jp.md CHANGED
@@ -299,34 +299,51 @@ class ExampleApiClient < MyApiClient::Base
299
299
  end
300
300
  ```
301
301
 
302
- `my_api_client_stub` を使うことで、 `ExampleApiClient#request` をスタブ化することができます。これで `#request` を実行してもリアルな HTTP リクエストが実行されなくなります。
302
+ `stub_api_client_all` や `stub_api_client` を使うことで、 `ExampleApiClient#request` をスタブ化することができます。これで `#request` を実行してもリアルな HTTP リクエストが実行されなくなります。
303
303
 
304
304
  ```ruby
305
- my_api_client_stub(ExampleApiClient, :request, response: { id: 12345 })
305
+ stub_api_client_all(
306
+ ExampleApiClient,
307
+ request: { response: { id: 12345 } }
308
+ )
306
309
 
307
310
  response = ExampleApiClient.new.request(user_id: 1)
308
311
  response.id # => 12345
309
312
  ```
310
313
 
311
- リクスエストパラメータを使ったレスポンスを返すようにスタブ化したい場合は、 `block` を利用することで実現できます。
314
+ `response` は省略することも可能です。
312
315
 
313
316
  ```ruby
314
- my_api_client_stub(ExampleApiClient, :request) do |params|
315
- { id: params[:user_id] }
316
- end
317
+ stub_api_client_all(
318
+ ExampleApiClient,
319
+ request: { id: 12345 }
320
+ )
321
+
322
+ response = ExampleApiClient.new.request(user_id: 1)
323
+ response.id # => 12345
324
+ ```
325
+
326
+
327
+ リクスエストパラメータを使ったレスポンスを返すようにスタブ化したい場合は、 `Proc` を利用することで実現できます。
328
+
329
+ ```ruby
330
+ stub_api_client_all(
331
+ ExampleApiClient,
332
+ request: ->(params) { { id: params[:user_id] } }
333
+ )
317
334
 
318
335
  response = ExampleApiClient.new.request(user_id: 1)
319
336
  response.id # => 1
320
337
  ```
321
338
 
322
- `receive` や `have_received` を使ったテストを書きたい場合は、 `my_api_client_stub` の戻り値を利用すると良いでしょう。
339
+ `receive` や `have_received` を使ったテストを書きたい場合は、 `stub_api_client_all` や `stub_api_client` の戻り値を利用すると良いでしょう。
323
340
 
324
341
  ```ruby
325
342
  def execute_api_request
326
343
  ExampleApiClient.new.request(user_id: 1)
327
344
  end
328
345
 
329
- api_clinet = my_api_client_stub(ExampleApiClient, :request)
346
+ api_clinet = stub_api_client_all(ExampleApiClient, request: nil)
330
347
  execute_api_request
331
348
  expect(api_client).to have_received(:request).with(user_id: 1)
332
349
  ```
@@ -338,7 +355,7 @@ def execute_api_request
338
355
  ExampleApiClient.new.request(user_id: 1)
339
356
  end
340
357
 
341
- my_api_client_stub(ExampleApiClient, :request, raise: MyApiClient::Error)
358
+ stub_api_client_all(ExampleApiClient, request: { raise: MyApiClient::Error })
342
359
  expect { execute_api_request }.to raise_error(MyApiClient::Error)
343
360
  ```
344
361
 
@@ -14,7 +14,7 @@ module MyApiClient
14
14
  # stub_api_client_all(
15
15
  # ExampleApiClient,
16
16
  # get_user: { response: { id: 1 } }, # Returns an arbitrary response.
17
- # post_users: { status: 'created' }, # You can ommit `response` keyword.
17
+ # post_users: { id: 1 }, # You can ommit `response` keyword.
18
18
  # patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
19
19
  # delete_user: { raise: MyApiClient::ClientError } # Raises an arbitrary error.
20
20
  # )
@@ -38,7 +38,7 @@ module MyApiClient
38
38
  # api_client = stub_api_client(
39
39
  # ExampleApiClient,
40
40
  # get_user: { response: { id: 1 } }, # Returns an arbitrary response.
41
- # post_users: { status: 'created' }, # You can ommit `response` keyword.
41
+ # post_users: { id: 1 }, # You can ommit `response` keyword.
42
42
  # patch_user: ->(params) { { id: params[:id] } }, # Returns calculated result as response.
43
43
  # delete_user: { raise: MyApiClient::ClientError } # Raises an arbitrary error.
44
44
  # )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyApiClient
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryz310
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-25 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport