soapy_bing 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65a3fd44b151237e0803cddd7d9bf6988e2469e546b4415f0d296e263e01b81b
4
- data.tar.gz: a96527f1a48c50549cba94dcdbe06a4f0f91c510a93b0abd8e1869747dc2a8fe
3
+ metadata.gz: 410ca0200523029aee0ca775e0c1cd2e986d8f06e8052125f0f29a2a1ab6bbca
4
+ data.tar.gz: e60d34bd896baff2a38484d7e92aac4d3eeb28d899e3d951e6fb31cd73455f9c
5
5
  SHA512:
6
- metadata.gz: 7a604992207260d32a2fe6cfe0c445473b61588f7f03fd096c5e02c54cc6876be0a3278accb911d7cb7be5727555139dc801aa922b5c816b3422514e21da61fb
7
- data.tar.gz: a1f16463696c50f2926e92ff98e3838695d38c0f1bc6224a312f95b327a294566ea3c6e48acd822c7191d7e0be1489f50ca2ee4917f620737795c4f83a129319
6
+ metadata.gz: 6e8de7b6c64bc206576b1715819ac7e9dd32a244197d1cc1b4e0ac33004ae559fd93b5f382a984d2e311c2c66fcdffe8f56dbdf7d10352e1f8a8d9c8a4b54fab
7
+ data.tar.gz: c4c91a28b008659e3a571359e745297975c6d743c482cd1f6b62f5814aec4b998cb3b6777bfacb7ce0303cdd0e691d87ab20e88c49cb692e541e7cea017d129a
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.1] - 2019-03-13
8
+ ### Changed
9
+ - Pass along the server's error message to `TokenRefreshError`
10
+
7
11
  ## [1.0.0] - 2019-01-28
8
12
  ### Added
9
13
  - This CHANGELOG
@@ -27,7 +27,9 @@ module SoapyBing
27
27
  def request_access_token
28
28
  resp = HTTParty.post(token_url, body: access_token_params)
29
29
 
30
- raise TokenRefreshError unless resp.code == 200
30
+ if resp.code != 200
31
+ raise TokenRefreshError, "#{resp['error_description']} (#{resp['error']})"
32
+ end
31
33
 
32
34
  resp['access_token']
33
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SoapyBing
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
@@ -83,28 +83,37 @@ RSpec.describe SoapyBing::OauthCredentials do
83
83
 
84
84
  describe '#access_token' do
85
85
  let(:credentials) { { client_id: 'foo', client_secret: 'bar', refresh_token: 'baz' } }
86
- let(:response) { double(:response) } # rubocop:disable RSpec/VerifiedDoubles
86
+ let(:response) do
87
+ HTTParty::Response.new(
88
+ OpenStruct.new(options: {}),
89
+ OpenStruct.new(code: status_code),
90
+ -> { response_body }
91
+ )
92
+ end
87
93
 
88
94
  before do
89
- allow(response).to receive(:code).once.and_return(status_code)
90
95
  allow(HTTParty).to receive(:post).once.and_return(response)
91
96
  end
92
97
 
93
98
  context 'when there is good response' do
94
99
  let(:status_code) { 200 }
100
+ let(:response_body) { { 'access_token' => 'my-token' } }
95
101
 
96
102
  it 'memoizes http request response' do
97
- expect(response).to receive(:[]).once.with('access_token').and_return('my-token')
98
103
  2.times { expect(oauth_credentials.access_token).to eq 'my-token' }
99
104
  end
100
105
  end
101
106
 
102
107
  context 'when there is bad response' do
103
108
  let(:status_code) { 401 }
109
+ let(:response_body) do
110
+ { 'error' => 'my-error', 'error_description' => 'This is my error.' }
111
+ end
104
112
 
105
113
  it 'throws exception in case of bad status code' do
106
114
  expect { oauth_credentials.access_token }.to raise_error(
107
- SoapyBing::OauthCredentials::TokenRefreshError
115
+ SoapyBing::OauthCredentials::TokenRefreshError,
116
+ 'This is my error. (my-error)'
108
117
  )
109
118
  end
110
119
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapy_bing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-28 00:00:00.000000000 Z
11
+ date: 2019-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -299,8 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
299
  - !ruby/object:Gem::Version
300
300
  version: '0'
301
301
  requirements: []
302
- rubyforge_project:
303
- rubygems_version: 2.7.6
302
+ rubygems_version: 3.0.2
304
303
  signing_key:
305
304
  specification_version: 4
306
305
  summary: Simple client for the Bing Ads APIs