Skip to content

Commit

Permalink
Support Faraday v1 and v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nipe0324 committed Oct 15, 2023
1 parent 54ec806 commit 532a9c0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ on:

jobs:
rspec:
name: Faraday ${{ matrix.faraday }}
runs-on: ubuntu-latest
strategy:
matrix:
faraday:
- ~> 0.17
- ~> 1.0
- ~> 2.0
env:
FARADAY_VERSION: ${{ matrix.faraday }}
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.0'
bundler-cache: true
- run: gem install bundler -v '< 2.0'
- run: gem install bundler
- run: bundle install
- run: bundle exec rake spec
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

- Support Faraday v1 and v2

## v1.4.0

- Migrate CI/CD platform from Travis CI to GitHub Actions
Expand Down
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
source 'https://rubygems.org'

# Support Faraday 0.x, 1.x and 2.x
faraday_version = ENV.fetch('FARADAY_VERSION', '~> 2.0')
gem 'faraday', faraday_version

if faraday_version.start_with?(/~> (0|1)/)
gem 'faraday_middleware'
end

# Specify your gem's dependencies in qiita.gemspec
gemspec
2 changes: 1 addition & 1 deletion lib/qiita.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/string/strip"
require "faraday"
require "faraday_middleware"
require "faraday_middleware" if Faraday::VERSION.start_with?(/0|1/)
require "json"
require "rack/utils"
require "rainbow"
Expand Down
5 changes: 2 additions & 3 deletions qiita.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "activesupport"
spec.add_dependency "faraday", "~> 0.9"
spec.add_dependency "faraday_middleware"
spec.add_dependency "faraday", ">= 0.17", "< 3.0"
spec.add_dependency "rack"
spec.add_dependency "rainbow"
spec.add_dependency "rouge"
Expand All @@ -27,5 +26,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "pry"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "webmock", "1.20.4"
spec.add_development_dependency "webmock", "~> 3"
end
8 changes: 8 additions & 0 deletions spec/qiita/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ def stub_api_request
204
end

let(:response_hash) do
nil
end

include_examples "valid condition"
include_examples "sends request with JSON-encoded body"
end
Expand All @@ -362,6 +366,10 @@ def stub_api_request
204
end

let(:response_hash) do
nil
end

include_examples "valid condition"
include_examples "sends request with URL query"
end
Expand Down

0 comments on commit 532a9c0

Please sign in to comment.