From c59a0da6691982a815bf8cc52db51456d6d484a5 Mon Sep 17 00:00:00 2001 From: Pieter van Laatum Date: Tue, 26 Jul 2022 14:54:10 +0200 Subject: [PATCH 1/8] Update Faraday --- .circleci/config.yml | 4 ++-- Gemfile | 2 +- Gemfile.lock | 24 ++++-------------------- plonquo_faraday_wrapper.gemspec | 4 ++-- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 015baa2..fd2c971 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,14 +6,14 @@ orbs: jobs: test: docker: - - image: cimg/ruby:2.7 + - image: cimg/ruby:3.1 steps: - checkout - ruby/install-deps - ruby/rspec-test deploy: docker: - - image: cimg/ruby:2.7 + - image: cimg/ruby:3.1 steps: - checkout - ruby/install-deps diff --git a/Gemfile b/Gemfile index 4ce1a65..2cfb554 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source 'https://rubygems.org' git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } gem 'byebug' -gem 'faraday', '~> 1.8' +gem 'faraday', '~> 2.3' gem 'rake' gem 'rspec', require: 'spec' gem 'rspec_junit_formatter' diff --git a/Gemfile.lock b/Gemfile.lock index eecc567..7d65ecc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,27 +4,11 @@ GEM ast (2.4.2) byebug (11.1.3) diff-lcs (1.4.4) - faraday (1.8.0) - faraday-em_http (~> 1.0) - faraday-em_synchrony (~> 1.0) - faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0.1) - faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.1) - faraday-patron (~> 1.0) - faraday-rack (~> 1.0) - multipart-post (>= 1.2, < 3) + faraday (2.3.0) + faraday-net_http (~> 2.0) ruby2_keywords (>= 0.0.4) - faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) - faraday-excon (1.1.0) - faraday-httpclient (1.0.1) - faraday-net_http (1.0.1) - faraday-net_http_persistent (1.2.0) - faraday-patron (1.0.0) - faraday-rack (1.0.0) + faraday-net_http (2.0.3) json (2.6.2) - multipart-post (2.1.1) parallel (1.22.1) parser (3.1.2.0) ast (~> 2.4.1) @@ -68,7 +52,7 @@ PLATFORMS DEPENDENCIES byebug - faraday (~> 1.8) + faraday (~> 2.3) rake rspec rspec_junit_formatter diff --git a/plonquo_faraday_wrapper.gemspec b/plonquo_faraday_wrapper.gemspec index 3d08fd5..29e46af 100644 --- a/plonquo_faraday_wrapper.gemspec +++ b/plonquo_faraday_wrapper.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'faraday-wrapper' - s.required_ruby_version = '~> 2.7' + s.required_ruby_version = '>= 2.6' s.version = '1.2.5' s.date = '2019-07-19' s.summary = 'PlonquoFaradayWrapper' @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.license = 'MIT' s.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/Fabriquartz" - s.add_runtime_dependency 'faraday', '< 0.16' + s.add_runtime_dependency 'faraday', '~> 2.3' s.add_development_dependency 'rake' s.add_development_dependency 'rspec', '~> 3.7' From c9f57a2e5a405a3a32fb8d81cc4104e6510c10f7 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 28 Jul 2022 11:50:50 +0200 Subject: [PATCH 2/8] Update plonquo_faraday_wrapper.rb --- lib/plonquo_faraday_wrapper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plonquo_faraday_wrapper.rb b/lib/plonquo_faraday_wrapper.rb index 269a97c..2a91a42 100644 --- a/lib/plonquo_faraday_wrapper.rb +++ b/lib/plonquo_faraday_wrapper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class PlonquoFaradayWrapper +class FaradayWrapper require 'faraday' require 'json' attr_accessor :conn, :token, :user, :no_auth_required From a62112e6ebc4bbdaa1d0b37344188550b2e23ec4 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 28 Jul 2022 11:51:17 +0200 Subject: [PATCH 3/8] Rename plonquo_faraday_wrapper.rb to faraday_wrapper.rb --- lib/{plonquo_faraday_wrapper.rb => faraday_wrapper.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/{plonquo_faraday_wrapper.rb => faraday_wrapper.rb} (100%) diff --git a/lib/plonquo_faraday_wrapper.rb b/lib/faraday_wrapper.rb similarity index 100% rename from lib/plonquo_faraday_wrapper.rb rename to lib/faraday_wrapper.rb From 9287e8e514eedf383290e2c611829124c74bbc9a Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 28 Jul 2022 11:52:33 +0200 Subject: [PATCH 4/8] Update plonquo_faraday_wrapper.gemspec --- plonquo_faraday_wrapper.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plonquo_faraday_wrapper.gemspec b/plonquo_faraday_wrapper.gemspec index 29e46af..93de708 100644 --- a/plonquo_faraday_wrapper.gemspec +++ b/plonquo_faraday_wrapper.gemspec @@ -5,13 +5,13 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.6' s.version = '1.2.5' s.date = '2019-07-19' - s.summary = 'PlonquoFaradayWrapper' - s.description = 'PlonquoFaradayWrapper is a wrapper around the faraday gem for Fabriquartz Micro-Services' + s.summary = 'FaradayWrapper' + s.description = 'FaradayWrapper is a wrapper around the faraday gem for Fabriquartz Micro-Services' s.authors = ['Cédric Remond'] s.email = 'cedric.remond@fabriquartz.com' - s.files = ['lib/plonquo_faraday_wrapper.rb'] + s.files = ['lib/faraday_wrapper.rb'] s.homepage = - 'https://rubygems.org/gems/plonquo-request' + 'https://github.com/Fabriquartz/faraday-wrapper' s.license = 'MIT' s.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/Fabriquartz" From 1e115a022b344532eaf2ff3ea16268c29a11a037 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 28 Jul 2022 11:53:26 +0200 Subject: [PATCH 5/8] Update plonquo_faraday_wrapper_spec.rb --- spec/plonquo_faraday_wrapper_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/plonquo_faraday_wrapper_spec.rb b/spec/plonquo_faraday_wrapper_spec.rb index a7f25f3..a630506 100644 --- a/spec/plonquo_faraday_wrapper_spec.rb +++ b/spec/plonquo_faraday_wrapper_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -RSpec.describe PlonquoFaradayWrapper do +RSpec.describe FaradayWrapper do describe '#ssl_verification' do - let!(:wrapper) { PlonquoFaradayWrapper.new('https://staging.calipri.plonquo.io', options) } + let!(:wrapper) { FaradayWrapper.new('https://staging.calipri.plonquo.io', options) } let!(:random) { options[:ssl_verification] } let(:ssl_verify) { wrapper.conn.ssl.verify } @@ -33,44 +33,44 @@ end it 'initailizes a faraday instance with the correct url' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') expect(wrapper.conn.url_prefix.to_s).to eq 'https://json-api-staging.rail.io/' end it 'raises a error when no token or credentials are given' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') expect { wrapper.authenticate }.to raise_error(ArgumentError, 'No access token or (complete) login credentials found in options hash') end it 'raises a error when partial credentials are given' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') expect { wrapper.authenticate(username: 'cedric.remond@fabriquartz.nl') }.to raise_error(ArgumentError, 'No access token or (complete) login credentials found in options hash') end it 'raises a error when the get method is called without being authenticated' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') expect { wrapper.get('/users') }.to raise_error(StandardError, 'Not authenticated, use the authenticate method to login by token or credentials') end it 'raises a error when the post method is called without being authenticated' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') expect { wrapper.post('/users') }.to raise_error(StandardError, 'Not authenticated, use the authenticate method to login by token or credentials') end it 'raises a error when the request method is called without being post or get defined' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') options = { url: 'http://localhost:3000/', path: '/users/current', headers: { 'Content-Type': 'application/json', Authorization: 'Basic Y2VkcmljLnJlbW9uZEBmYWJyaXF1YXJ0ei5jb206V2FhbG5vcmQxMDIx' } } expect { wrapper.request(options) }.to raise_error(ArgumentError, 'Please define post or get in the method call') end it 'raises a error when the request method is called without being post or get defined' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') options = { url: 'http://localhost:3000/', path: '/users/current', headers: { 'Content-Type': 'application/json', Authorization: 'Basic Y2VkcmljLnJlbW9uZEBmYWJyaXF1YXJ0ei5jb206V2FhbG5vcmQxMDIx' } } expect { wrapper.request(options) }.to raise_error(ArgumentError, 'Please define post or get in the method call') end it 'raises a error when the request method is called without a path in the options hash' do - wrapper = PlonquoFaradayWrapper.new('https://json-api-staging.rail.io/') + wrapper = FaradayWrapper.new('https://json-api-staging.rail.io/') options = { url: 'http://localhost:3000/', headers: { 'Content-Type': 'application/json', Authorization: 'Basic Y2VkcmljLnJlbW9uZEBmYWJyaXF1YXJ0ei5jb206V2FhbG5vcmQxMDIx' } } expect { wrapper.request('post', options) }.to raise_error(ArgumentError, 'Please define a path in the options hash to call') end From 2aa75c83c89a757c96c20eb1bc7213aef52720b4 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 28 Jul 2022 11:54:12 +0200 Subject: [PATCH 6/8] Rename plonquo_faraday_wrapper_spec.rb to faraday_wrapper_spec.rb --- spec/{plonquo_faraday_wrapper_spec.rb => faraday_wrapper_spec.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/{plonquo_faraday_wrapper_spec.rb => faraday_wrapper_spec.rb} (100%) diff --git a/spec/plonquo_faraday_wrapper_spec.rb b/spec/faraday_wrapper_spec.rb similarity index 100% rename from spec/plonquo_faraday_wrapper_spec.rb rename to spec/faraday_wrapper_spec.rb From 1d640dc786cc6fd7df3f8e784d30210cf55d5c47 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 28 Jul 2022 11:57:25 +0200 Subject: [PATCH 7/8] Rename plonquo_faraday_wrapper.gemspec to faraday_wrapper.gemspec --- plonquo_faraday_wrapper.gemspec => faraday_wrapper.gemspec | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plonquo_faraday_wrapper.gemspec => faraday_wrapper.gemspec (100%) diff --git a/plonquo_faraday_wrapper.gemspec b/faraday_wrapper.gemspec similarity index 100% rename from plonquo_faraday_wrapper.gemspec rename to faraday_wrapper.gemspec From 81c2953769a1bce6b30d2f39d46410606ca102b5 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 28 Jul 2022 11:58:35 +0200 Subject: [PATCH 8/8] Update spec_helper.rb --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2838bca..6c34dbc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'plonquo_faraday_wrapper' +require 'faraday_wrapper' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure