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

Feature/#762 rspec #832

Merged
merged 52 commits into from Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
b910c06
Adds RSpec minimal config
iMacTia Jan 27, 2018
dbd2588
Faraday::Utils specs
iMacTia Jan 27, 2018
e45b970
Adds specs for Faraday::Response::Middleware and Faraday::Response::R…
iMacTia Jan 27, 2018
fcc2f49
Adds specs for Faraday::Response::Logger
iMacTia Jan 27, 2018
6842a8e
Removes minitests that have been turned into specs
iMacTia Jan 27, 2018
2f550e6
Puts back `strawberry.rb` file as it's used by some test...
iMacTia Jan 29, 2018
2596fbb
Merge branch '1.0' of https://github.com/lostisland/faraday into feat…
iMacTia Feb 10, 2018
72ae7ca
Converts request_middleware_test into rspec
iMacTia Feb 10, 2018
2230667
Converts parameters_test into rspec
iMacTia Feb 10, 2018
46b16f5
Converts options_test into rspec
iMacTia Feb 11, 2018
fe9c30e
Disables minimum coverage for MiniTest
iMacTia Feb 11, 2018
97bd2e8
Introduces webmock
iMacTia Feb 11, 2018
cc3fed6
fix
iMacTia Feb 11, 2018
296fc9b
Adds tests for Excon, HTTPClient, NetHTTPPersistent, Patron and Typho…
iMacTia Feb 18, 2018
ce7c730
Merge branch '1.0' of https://github.com/lostisland/faraday into feat…
iMacTia Mar 8, 2018
d3ec206
Allows to configure features on a per-adapter base
iMacTia Mar 8, 2018
1610d30
Adds common #post adapter tests
iMacTia Mar 8, 2018
575a4af
Isolate http methods tests into a set of shared examples
iMacTia Mar 8, 2018
5c544e6
Skips some tests under Patron as there's an issue with PATCH body (ht…
iMacTia Mar 13, 2018
fc3542f
fixes
iMacTia Mar 19, 2018
1030d2e
Streaming WIP
iMacTia Mar 26, 2018
79746fd
Finish converting streaming tests.
iMacTia Mar 30, 2018
eb08c1e
Updates webmock to fix patron issue with PATCH requests.
iMacTia May 31, 2018
c4f03b7
Merge branch '1.0' of https://github.com/lostisland/faraday into feat…
iMacTia Jul 21, 2018
bac1da1
Merge branch '1.0' of https://github.com/lostisland/faraday into feat…
iMacTia Sep 21, 2018
50b8568
Fixes small issue with logger spec
iMacTia Sep 21, 2018
752b64f
Switches travis to use RSpec instead of MiniTest
iMacTia Sep 21, 2018
54b24cd
Converts autorization middleware tests.
iMacTia Sep 21, 2018
f774396
Style fixes to headers.rb
iMacTia Sep 28, 2018
7cfc584
Ignores /spec folder from when calculating coverage %.
iMacTia Sep 28, 2018
e1d7548
Test SSL enabled and disabled in the same test run.
iMacTia Sep 28, 2018
20cff7b
Actaully, let's remove it!
iMacTia Sep 28, 2018
e137e0b
Fix proxy and timeout tests.
iMacTia Oct 3, 2018
374ffed
Converts adapters tests to RSpec.
iMacTia Oct 15, 2018
6f46db6
Converts instrumentation tests to RSpec.
iMacTia Oct 15, 2018
30fb4b7
Converts retry middleware tests to RSpec.
iMacTia Oct 29, 2018
62d3f95
Adds new parameters_tests to nested_spec
iMacTia Oct 29, 2018
89df1a1
Merge branch '1.0' of https://github.com/lostisland/faraday into feat…
iMacTia Oct 29, 2018
340122a
Merge branch '1.0' of https://github.com/lostisland/faraday into feat…
iMacTia Oct 29, 2018
f0ff87b
Converts composite_read_io tests into RSpec
iMacTia Oct 29, 2018
80fdc7e
Adds RSpec for Faraday::Error::ClientError
iMacTia Oct 29, 2018
d49ad85
Converts RackBuilder tests into specs.
iMacTia Oct 30, 2018
393cb2c
No need to run tests twice anymore. SSL yes/no are now both tested.
iMacTia Oct 30, 2018
27b5d5e
Partially convert connection tests into RSpec.
iMacTia Nov 7, 2018
3bc27a2
More connection tests converted into RSpec.
iMacTia Nov 8, 2018
f016ebb
More connection tests converted into RSpec.
iMacTia Nov 8, 2018
e31d7af
More connection tests converted into RSpec.
iMacTia Nov 8, 2018
8826971
More connection tests converted into RSpec.
iMacTia Nov 8, 2018
e5c7f83
More connection tests converted into RSpec.
iMacTia Nov 8, 2018
8b1c857
Complete connection tests convertion into RSpec.
iMacTia Nov 9, 2018
58a3174
Merge branch '1.0' of https://github.com/lostisland/faraday into feat…
iMacTia Nov 26, 2018
4325812
Converts new Net::HTTP::Persistent pool_size tests to Rspec.
iMacTia Nov 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -7,9 +7,9 @@ pkg/*
tmp
.rvmrc
.ruby-version
.yardoc

## BUNDLER
bin
*.gem
.bundle
Gemfile.lock
Expand Down
3 changes: 3 additions & 0 deletions .rspec
@@ -0,0 +1,3 @@
--require spec_helper
--format documentation
--color
7 changes: 0 additions & 7 deletions .travis.yml
@@ -1,17 +1,11 @@
sudo: false
language: ruby
script: bundle exec script/test
cache: bundler

rvm:
- 2.3
- 2.4
- 2.5
- ruby-head
env:
matrix:
- SSL=no
- SSL=yes
deploy:
provider: rubygems
api_key:
Expand All @@ -21,5 +15,4 @@ deploy:
tags: true
repo: lostisland/faraday
rvm: 2.5
condition: '"$SSL" = "yes"'

6 changes: 6 additions & 0 deletions Gemfile
Expand Up @@ -6,6 +6,10 @@ gem 'ffi-ncurses', '~> 0.3', :platforms => :jruby
gem 'jruby-openssl', '~> 0.8.8', :platforms => :jruby
gem 'rake'

group :development, :test do
gem 'pry'
end

group :test do
gem 'coveralls', :require => false
gem 'em-http-request', '>= 1.1', :require => 'em-http'
Expand All @@ -22,6 +26,8 @@ group :test do
gem 'simplecov'
gem 'sinatra', '~> 1.3'
gem 'typhoeus', '~> 1.3', :require => 'typhoeus'
gem 'rspec', '~> 3.7'
gem 'webmock', '~> 3.4'
end

gemspec
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -4,5 +4,5 @@ task :default => :test

desc "Run all tests"
task :test do
exec 'script/test'
exec 'rspec'
end
14 changes: 14 additions & 0 deletions bin/console
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'faraday'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require 'irb'
IRB.start(__FILE__)
8 changes: 8 additions & 0 deletions bin/setup
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
9 changes: 9 additions & 0 deletions lib/faraday.rb
Expand Up @@ -17,6 +17,8 @@
#
module Faraday
VERSION = "0.15.3"
METHODS_WITH_QUERY = %w[get head delete]
METHODS_WITH_BODY = %w[post put patch]

class << self
# The root path that Faraday is being loaded from.
Expand Down Expand Up @@ -198,6 +200,13 @@ def register_middleware(autoload_path = nil, mapping = nil)
end
end

# Unregister a previously registered middleware class.
#
# @param key [Symbol] key for the registered middleware.
def unregister_middleware(key)
@registered_middleware.delete(key)
end

# Lookup middleware class with a registered Symbol shortcut.
#
# @param key [Symbol] key for the registered middleware.
Expand Down
3 changes: 2 additions & 1 deletion lib/faraday/adapter/patron.rb
Expand Up @@ -81,7 +81,8 @@ def configure_ssl(session, ssl)

private

CURL_TIMEOUT_MESSAGES = [ "Connection time-out",
CURL_TIMEOUT_MESSAGES = [
"Connection time-out",
"Connection timed out",
"Timed out before name resolve",
"server connect has timed out",
Expand Down
6 changes: 3 additions & 3 deletions lib/faraday/connection.rb
Expand Up @@ -160,7 +160,7 @@ def headers=(hash)
# @return [Faraday::Response]

# @!visibility private
%w[get head delete].each do |method|
METHODS_WITH_QUERY.each do |method|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{method}(url = nil, params = nil, headers = nil)
run_request(:#{method}, url, nil, headers) { |request|
Expand All @@ -170,7 +170,7 @@ def #{method}(url = nil, params = nil, headers = nil)
end
RUBY
end

# @!method post(url = nil, body = nil, headers = nil)
# Makes a POST HTTP request with a body.
# @!scope class
Expand Down Expand Up @@ -217,7 +217,7 @@ def #{method}(url = nil, params = nil, headers = nil)
# @return [Faraday::Response]

# @!visibility private
%w[post put patch].each do |method|
METHODS_WITH_BODY.each do |method|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{method}(url = nil, body = nil, headers = nil, &block)
run_request(:#{method}, url, body, headers, &block)
Expand Down
19 changes: 11 additions & 8 deletions lib/faraday/error.rb
@@ -1,6 +1,7 @@
module Faraday
# Faraday error base class.
class Error < StandardError; end
class Error < StandardError;
end

# Faraday client error class.
class ClientError < Error
Expand Down Expand Up @@ -45,15 +46,18 @@ def inspect
end

# A unified client error for failed connections.
class ConnectionFailed < ClientError; end
class ConnectionFailed < ClientError;
end

# A 404 error used in the RaiseError middleware
#
# @see Faraday::Response::RaiseError
class ResourceNotFound < ClientError; end

class ResourceNotFound < ClientError;
end

# Raised by FaradayMiddleware::ResponseMiddleware
class ParsingError < ClientError; end
class ParsingError < ClientError;
end

# A unified client error for timeouts.
class TimeoutError < ClientError
Expand All @@ -69,12 +73,11 @@ class SSLError < ClientError
# Exception used to control the Retry middleware.
#
# @see Faraday::Request::Retry
class RetriableResponse < ClientError; end
class RetriableResponse < ClientError;
end

[:ClientError, :ConnectionFailed, :ResourceNotFound,
:ParsingError, :TimeoutError, :SSLError, :RetriableResponse].each do |const|
Error.const_set(const, Faraday.const_get(const))
end


end
8 changes: 4 additions & 4 deletions lib/faraday/rack_builder.rb
Expand Up @@ -52,8 +52,8 @@ def build(app)
end
end

def initialize(handlers = [])
@adapter = nil
def initialize(handlers = [], adapter = nil)
@adapter = adapter
@handlers = handlers
if block_given?
build(&Proc.new)
Expand Down Expand Up @@ -176,11 +176,11 @@ def to_app(inner_app)
end

def ==(other)
other.is_a?(self.class) && @handlers == other.handlers
other.is_a?(self.class) && @handlers == other.handlers && @adapter == other.adapter
end

def dup
self.class.new(@handlers.dup)
self.class.new(@handlers.dup, @adapter.dup)
end

# ENV Keys
Expand Down