Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Faraday v1 and v2 #21

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

@nipe0324 nipe0324 Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns empty body response if 204 status code.

bblimke/webmock#190

And, Qiita PUT and DELETE APIs return a empty body.

JSON Schema(en): https://qiita.com/api/v2/schema?locale=en


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