Skip to content
Open
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
24 changes: 4 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -68,7 +52,7 @@ PLATFORMS

DEPENDENCIES
byebug
faraday (~> 1.8)
faraday (~> 2.3)
rake
rspec
rspec_junit_formatter
Expand Down
12 changes: 6 additions & 6 deletions plonquo_faraday_wrapper.gemspec → faraday_wrapper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

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'
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"

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'
Expand Down
2 changes: 1 addition & 1 deletion lib/plonquo_faraday_wrapper.rb → lib/faraday_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class PlonquoFaradayWrapper
class FaradayWrapper
require 'faraday'
require 'json'
attr_accessor :conn, :token, :user, :no_auth_required
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down