Skip to content

Commit

Permalink
Require Faraday >= 1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed May 9, 2020
1 parent e3f7a77 commit 7a0965c
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 0.1.1 (Next)
### 0.2.0 (Next)

* [#12](https://github.com/dblock/open-weather-ruby-client/pull/12): Cache Faraday::Connection for persistent adapters - [@dblock](https://github.com/dblock).
* [#12](https://github.com/dblock/open-weather-ruby-client/pull/12): Cache `Faraday::Connection` for persistent adapters - [@dblock](https://github.com/dblock).
* [#13](https://github.com/dblock/open-weather-ruby-client/pull/13): Require Faraday >= 1.0 - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.1.0 (2020/05/01)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ data.name # => 'Лондон'

## Errors

All errors that return HTTP codes 400-600 result in either `Faraday::Error::ResourceNotFound`, `Faraday::Error::ConnectionFailed` or [OpenWeather::Errors::Fault](lib/open_weather/errors/fault.rb) exceptions.
All errors that return HTTP codes 400-600 result in either `Faraday::ResourceNotFound`, `Faraday::ConnectionFailed` or [OpenWeather::Errors::Fault](lib/open_weather/errors/fault.rb) exceptions.

## Resources

Expand Down
4 changes: 2 additions & 2 deletions lib/open_weather/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class RaiseError < ::Faraday::Response::Middleware
def on_complete(env)
case env[:status]
when 404
raise Faraday::Error::ResourceNotFound, response_values(env)
raise Faraday::ResourceNotFound, response_values(env)
when 407
# mimic the behavior that we get with proxy requests with HTTPS
raise Faraday::Error::ConnectionFailed, %(407 "Proxy Authentication Required ")
raise Faraday::ConnectionFailed, %(407 "Proxy Authentication Required ")
when (400...600).freeze
raise OpenWeather::Errors::Fault, response_values(env)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/open_weather/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module OpenWeather
VERSION = '0.1.1'
VERSION = '0.2.0'
end
2 changes: 1 addition & 1 deletion open-weather-ruby-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.licenses = ['MIT']
s.summary = 'OpenWeather API Ruby client.'
s.add_dependency 'activesupport'
s.add_dependency 'faraday', '>= 0.9'
s.add_dependency 'faraday', '>= 1.0.0'
s.add_dependency 'faraday_middleware'
s.add_dependency 'hashie'
end
44 changes: 44 additions & 0 deletions spec/fixtures/open_weather/errors/connection_failed.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions spec/fixtures/open_weather/errors/not_found.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions spec/open_weather/errors/connection_failed_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'connection failed' do
include_context 'API client'

it 'raises error', vcr: { cassette_name: 'errors/connection_failed' } do
expect { client.current_weather(city: 'London') }.to raise_error Faraday::ConnectionFailed
end
end
11 changes: 11 additions & 0 deletions spec/open_weather/errors/not_found_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'on not found' do
include_context 'API client'

it 'raises error', vcr: { cassette_name: 'errors/not_found' } do
expect { client.current_weather(city: 'London') }.to raise_error Faraday::ResourceNotFound
end
end

0 comments on commit 7a0965c

Please sign in to comment.