[DRE-commits] [ruby-patron] 01/04: Imported Upstream version 0.5.0
zeha at debian.org
zeha at debian.org
Thu Dec 17 00:06:10 UTC 2015
This is an automated email from the git hooks/post-receive script.
zeha pushed a commit to annotated tag debian/0.5.0-1
in repository ruby-patron.
commit 137070d96073253c0d9ce192f585f7fdcdfe75fe
Author: Christian Hofstaedtler <zeha at debian.org>
Date: Wed Dec 16 22:56:58 2015 +0000
Imported Upstream version 0.5.0
---
Gemfile.lock | 40 ++++++----
README.md | 17 ++++
Rakefile | 9 +--
ext/patron/extconf.rb | 4 +-
ext/patron/session_ext.c | 22 ++++--
lib/patron/request.rb | 6 +-
lib/patron/response.rb | 28 +++----
lib/patron/session.rb | 30 +++++--
lib/patron/version.rb | 2 +-
metadata.yml | 52 +++++--------
patron.gemspec | 2 +-
spec/patron_spec.rb | 4 +-
spec/request_spec.rb | 22 +++---
spec/response_spec.rb | 12 +--
spec/session_spec.rb | 198 +++++++++++++++++++++++++++++++++--------------
spec/session_ssl_spec.rb | 105 +++++++++++++------------
spec/spec_helper.rb | 10 +++
spec/util_spec.rb | 40 +++++-----
18 files changed, 368 insertions(+), 235 deletions(-)
diff --git a/Gemfile.lock b/Gemfile.lock
index b5fda1a..268659b 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -6,19 +6,30 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- diff-lcs (1.1.3)
- rake (0.9.2.2)
- rake-compiler (0.7.9)
+ diff-lcs (1.2.5)
+ docile (1.1.5)
+ json (1.8.3)
+ rake (10.4.2)
+ rake-compiler (0.9.5)
rake
- rcov (0.9.11)
- rspec (2.7.0)
- rspec-core (~> 2.7.0)
- rspec-expectations (~> 2.7.0)
- rspec-mocks (~> 2.7.0)
- rspec-core (2.7.1)
- rspec-expectations (2.7.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.7.0)
+ rspec (3.3.0)
+ rspec-core (~> 3.3.0)
+ rspec-expectations (~> 3.3.0)
+ rspec-mocks (~> 3.3.0)
+ rspec-core (3.3.2)
+ rspec-support (~> 3.3.0)
+ rspec-expectations (3.3.1)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.3.0)
+ rspec-mocks (3.3.2)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.3.0)
+ rspec-support (3.3.0)
+ simplecov (0.10.0)
+ docile (~> 1.1.0)
+ json (~> 1.8)
+ simplecov-html (~> 0.10.0)
+ simplecov-html (0.10.0)
PLATFORMS
ruby
@@ -27,5 +38,8 @@ DEPENDENCIES
bundler (>= 1.0.0)
patron!
rake-compiler (>= 0.7.5)
- rcov (>= 0.9.9)
rspec (>= 2.3.0)
+ simplecov (>= 0.10.0)
+
+BUNDLED WITH
+ 1.10.6
diff --git a/README.md b/README.md
index a941006..c0ff0bf 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,23 @@ requests:
sess.timeout = 10
sess.base_url = "http://myserver.com:9900"
sess.headers['User-Agent'] = 'myapp/1.0'
+
+You can set options with a hash in the constructor:
+
+ sess = Patron::Session.new({ :timeout => 10,
+ :base_url => 'http://myserver.com:9900',
+ :headers => {'User-Agent' => 'myapp/1.0'} } )
+
+Or the set options in a block:
+
+ sess = Patron::Session.new do |patron|
+ patron.timeout = 10
+ patron.base_url = 'http://myserver.com:9900'
+ patron.headers = {'User-Agent' => 'myapp/1.0'}
+ end
+
+Output debug log:
+
sess.enable_debug "/tmp/patron.debug"
The Session is used to make HTTP requests.
diff --git a/Rakefile b/Rakefile
index d2629e4..2af1c02 100644
--- a/Rakefile
+++ b/Rakefile
@@ -22,7 +22,7 @@
##
## -------------------------------------------------------------------
require 'rake/clean'
-require 'rake/rdoctask'
+require 'rdoc/task'
require 'rake/extensiontask'
require 'rspec/core/rake_task'
require 'bundler'
@@ -59,11 +59,4 @@ end
task :spec => [:compile]
-desc "Run specs with RCov"
-RSpec::Core::RakeTask.new('spec:rcov') do |t|
- t.pattern = 'spec/**/*_spec.rb'
- t.rcov = true
- t.rcov_opts = %q(--sort coverage --comments --exclude "spec")
-end
-
task :default => :spec
diff --git a/ext/patron/extconf.rb b/ext/patron/extconf.rb
index f370652..2495f33 100644
--- a/ext/patron/extconf.rb
+++ b/ext/patron/extconf.rb
@@ -44,6 +44,8 @@ if CONFIG['CC'] =~ /gcc/
end
$defs.push("-DUSE_TBR")
-$defs.push("-DHAVE_TBR") if have_func('rb_thread_blocking_region')
+$defs.push("-DHAVE_THREAD_H") if have_header('ruby/thread.h')
+$defs.push("-DHAVE_TBR") if have_func('rb_thread_blocking_region', 'ruby.h')
+$defs.push("-DHAVE_TCWOGVL") if have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
create_makefile 'patron/session_ext'
diff --git a/ext/patron/session_ext.c b/ext/patron/session_ext.c
index 2669ed3..4966fe6 100644
--- a/ext/patron/session_ext.c
+++ b/ext/patron/session_ext.c
@@ -23,6 +23,9 @@
*
\* -------------------------------------------------------------------------- */
#include <ruby.h>
+#if defined(USE_TBR) && defined(HAVE_THREAD_H)
+#include <ruby/thread.h>
+#endif
#include <curl/curl.h>
#include "membuffer.h"
#include "sglib.h" /* Simple Generic Library -> http://sglib.sourceforge.net */
@@ -109,7 +112,7 @@ struct curl_state_list {
struct curl_state_list *next;
};
-#define CS_LIST_COMPARATOR(p, _state_) (p->state == _state_)
+#define CS_LIST_COMPARATOR(p, _state_) (p->state - _state_)
static struct curl_state_list *cs_list = NULL;
@@ -128,9 +131,9 @@ static void cs_list_remove(struct curl_state *state) {
struct curl_state_list *item = NULL;
assert(state != NULL);
- SGLIB_LIST_FIND_MEMBER(struct curl_state_list, cs_list, state, CS_LIST_COMPARATOR, next, item);
+
+ SGLIB_LIST_DELETE_IF_MEMBER(struct curl_state_list, cs_list, state, CS_LIST_COMPARATOR, next, item);
if (item) {
- SGLIB_LIST_DELETE(struct curl_state_list, cs_list, item, next);
ruby_xfree(item);
}
}
@@ -355,7 +358,9 @@ static void set_options_from_request(VALUE self, VALUE request) {
}
action = SYM2ID(action_name);
-
+ if(rb_iv_get(request, "@force_ipv4")) {
+ curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
+ }
if (action == rb_intern("get")) {
VALUE data = rb_iv_get(request, "@upload_data");
VALUE download_file = rb_iv_get(request, "@file_name");
@@ -593,11 +598,18 @@ static VALUE perform_request(VALUE self) {
curl_easy_setopt(curl, CURLOPT_WRITEDATA, body_buffer);
}
-#if defined(HAVE_TBR) && defined(USE_TBR)
+#if (defined(HAVE_TBR) || defined(HAVE_TCWOGVL)) && defined(USE_TBR)
+#if defined(HAVE_TCWOGVL)
+ ret = (CURLcode) rb_thread_call_without_gvl(
+ (void *(*)(void *)) curl_easy_perform, curl,
+ RUBY_UBF_IO, 0
+ );
+#else
ret = (CURLcode) rb_thread_blocking_region(
(rb_blocking_function_t*) curl_easy_perform, curl,
RUBY_UBF_IO, 0
);
+#endif
#else
ret = curl_easy_perform(curl);
#endif
diff --git a/lib/patron/request.rb b/lib/patron/request.rb
index b7f7f1c..39cb8e6 100644
--- a/lib/patron/request.rb
+++ b/lib/patron/request.rb
@@ -46,12 +46,12 @@ module Patron
:url, :username, :password, :file_name, :proxy, :proxy_type, :insecure,
:ignore_content_length, :multipart, :action, :timeout, :connect_timeout,
:max_redirects, :headers, :auth_type, :upload_data, :buffer_size, :cacert,
- :ssl_version
+ :ssl_version, :force_ipv4
]
WRITER_VARS = [
:url, :username, :password, :file_name, :proxy, :proxy_type, :insecure,
- :ignore_content_length, :multipart, :cacert, :ssl_version
+ :ignore_content_length, :multipart, :cacert, :ssl_version, :force_ipv4
]
attr_reader *READER_VARS
@@ -110,7 +110,7 @@ module Patron
@connect_timeout = new_timeout.to_i
end
-
+
def max_redirects=(new_max_redirects)
if new_max_redirects.to_i < -1
raise ArgumentError, "Max redirects must be a positive integer, 0 or -1"
diff --git a/lib/patron/response.rb b/lib/patron/response.rb
index fdb524a..75123b2 100644
--- a/lib/patron/response.rb
+++ b/lib/patron/response.rb
@@ -85,20 +85,22 @@ module Patron
def parse_headers(header_data)
@headers = {}
- header_data.split(/\r\n/).each do |header|
- if header =~ %r|^HTTP/1.[01]|
- @status_line = header.strip
+ lines = header_data.split("\r\n")
+
+ @status_line = lines.shift
+
+ lines.each do |line|
+ break if line.empty?
+
+ hdr, val = line.split(":", 2)
+
+ val.strip! unless val.nil?
+
+ if @headers.key?(hdr)
+ @headers[hdr] = [@headers[hdr]] unless @headers[hdr].kind_of? Array
+ @headers[hdr] << val
else
- parts = header.split(':', 2)
- unless parts.empty?
- parts[1].strip! unless parts[1].nil?
- if @headers.has_key?(parts[0])
- @headers[parts[0]] = [@headers[parts[0]]] unless @headers[parts[0]].kind_of? Array
- @headers[parts[0]] << parts[1]
- else
- @headers[parts[0]] = parts[1]
- end
- end
+ @headers[hdr] = val
end
end
end
diff --git a/lib/patron/session.rb b/lib/patron/session.rb
index 2370b12..0b844ea 100644
--- a/lib/patron/session.rb
+++ b/lib/patron/session.rb
@@ -83,16 +83,31 @@ module Patron
# Default encoding of responses. Used if no charset is provided by the host.
attr_accessor :default_response_charset
+
+ # Force curl to use IPv4
+ attr_accessor :force_ipv4
private :handle_request, :enable_cookie_session, :set_debug_file
# Create a new Session object.
- def initialize
- @headers = {}
- @timeout = 5
- @connect_timeout = 1
- @max_redirects = 5
- @auth_type = :basic
+ def initialize(args = {}, &block)
+
+ # Allows accessors to be set via constructor hash. Ex: {:base_url => 'www.home.com'}
+ args.each do |attribute, value|
+ send("#{attribute}=", value)
+ end
+
+ # Allows accessors to be set via block.
+ if block_given?
+ yield self
+ end
+
+ @headers ||= {}
+ @timeout ||= 5
+ @connect_timeout ||= 1
+ @max_redirects ||= 5
+ @auth_type ||= :basic
+ @force_ipv4 ||= false
end
# Turn on cookie handling for this session, storing them in memory by
@@ -211,6 +226,7 @@ module Patron
req.headers = self.headers.merge headers
req.timeout = options.fetch :timeout, self.timeout
req.connect_timeout = options.fetch :connect_timeout, self.connect_timeout
+ req.force_ipv4 = options.fetch :force_ipv4, self.force_ipv4
req.max_redirects = options.fetch :max_redirects, self.max_redirects
req.username = options.fetch :username, self.username
req.password = options.fetch :password, self.password
@@ -229,7 +245,7 @@ module Patron
base_url = self.base_url.to_s
url = url.to_s
raise ArgumentError, "Empty URL" if base_url.empty? && url.empty?
- uri = URI.join(base_url, url)
+ uri = URI.parse(base_url.empty? ? url : File.join(base_url, url))
query = uri.query.to_s.split('&')
query += options[:query].is_a?(Hash) ? Util.build_query_pairs_from_hash(options[:query]) : options[:query].to_s.split('&')
uri.query = query.join('&')
diff --git a/lib/patron/version.rb b/lib/patron/version.rb
index a64437c..50080d5 100644
--- a/lib/patron/version.rb
+++ b/lib/patron/version.rb
@@ -1,3 +1,3 @@
module Patron
- VERSION = "0.4.20"
+ VERSION = "0.5.0"
end
diff --git a/metadata.yml b/metadata.yml
index 6055c99..9cbb28e 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,80 +1,71 @@
--- !ruby/object:Gem::Specification
name: patron
version: !ruby/object:Gem::Version
- version: 0.4.20
- prerelease:
+ version: 0.5.0
platform: ruby
authors:
- Phillip Toland
autorequire:
bindir: bin
cert_chain: []
-date: 2015-02-20 00:00:00.000000000 Z
+date: 2015-09-08 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: bundler
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 1.0.0
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 1.0.0
- !ruby/object:Gem::Dependency
name: rake-compiler
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 0.7.5
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 0.7.5
- !ruby/object:Gem::Dependency
name: rspec
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 2.3.0
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 2.3.0
- !ruby/object:Gem::Dependency
- name: rcov
+ name: simplecov
requirement: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
- version: 0.9.9
+ version: 0.10.0
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
- version: 0.9.9
+ version: 0.10.0
description: Ruby HTTP client library based on libcurl
email:
- phil.toland at gmail.com
@@ -83,9 +74,9 @@ extensions:
- ext/patron/extconf.rb
extra_rdoc_files: []
files:
-- .autotest
-- .gitignore
-- .rspec
+- ".autotest"
+- ".gitignore"
+- ".rspec"
- Gemfile
- Gemfile.lock
- LICENSE
@@ -121,27 +112,26 @@ files:
- spec/util_spec.rb
homepage: https://github.com/toland/patron
licenses: []
+metadata: {}
post_install_message:
rdoc_options: []
require_paths:
- lib
- ext
required_ruby_version: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
- none: false
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: 1.2.0
requirements: []
rubyforge_project: patron
-rubygems_version: 1.8.23
+rubygems_version: 2.4.5.1
signing_key:
-specification_version: 3
+specification_version: 4
summary: Patron HTTP Client
test_files: []
diff --git a/patron.gemspec b/patron.gemspec
index 2dc2ab0..fa07b16 100644
--- a/patron.gemspec
+++ b/patron.gemspec
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "bundler", ">= 1.0.0"
s.add_development_dependency "rake-compiler", ">= 0.7.5"
s.add_development_dependency "rspec", ">= 2.3.0"
- s.add_development_dependency "rcov", ">= 0.9.9"
+ s.add_development_dependency "simplecov", ">= 0.10.0"
s.files = `git ls-files`.split("\n")
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
diff --git a/spec/patron_spec.rb b/spec/patron_spec.rb
index 839ef11..1a403c6 100644
--- a/spec/patron_spec.rb
+++ b/spec/patron_spec.rb
@@ -27,12 +27,12 @@ describe Patron do
it "should return the version number of the Patron library" do
version = Patron.version
- version.should match(%r|^\d+.\d+.\d+$|)
+ expect(version).to match(%r|^\d+.\d+.\d+$|)
end
it "should return the version number of the libcurl library" do
version = Patron.libcurl_version
- version.should match(%r|^libcurl/\d+.\d+.\d+|)
+ expect(version).to match(%r|^libcurl/\d+.\d+.\d+|)
end
end
diff --git a/spec/request_spec.rb b/spec/request_spec.rb
index 4179926..68d365f 100644
--- a/spec/request_spec.rb
+++ b/spec/request_spec.rb
@@ -34,12 +34,12 @@ describe Patron::Request do
it "should accept :get, :put, :post, :delete and :head" do
[:get, :put, :post, :delete, :head, :copy].each do |action|
- lambda {@request.action = action}.should_not raise_error
+ expect {@request.action = action}.not_to raise_error
end
end
it "should raise an exception when assigned a bad value" do
- lambda {@request.action = :foo}.should raise_error(ArgumentError)
+ expect {@request.action = :foo}.to raise_error(ArgumentError)
end
end
@@ -47,11 +47,11 @@ describe Patron::Request do
describe :timeout do
it "should raise an exception when assigned a negative number" do
- lambda {@request.timeout = -1}.should raise_error(ArgumentError)
+ expect {@request.timeout = -1}.to raise_error(ArgumentError)
end
it "should raise an exception when assigned 0" do
- lambda {@request.timeout = 0}.should raise_error(ArgumentError)
+ expect {@request.timeout = 0}.to raise_error(ArgumentError)
end
end
@@ -59,7 +59,7 @@ describe Patron::Request do
describe :max_redirects do
it "should raise an error when assigned an integer smaller than -1" do
- lambda {@request.max_redirects = -2}.should raise_error(ArgumentError)
+ expect {@request.max_redirects = -2}.to raise_error(ArgumentError)
end
end
@@ -67,7 +67,7 @@ describe Patron::Request do
describe :headers do
it "should raise an error when assigned something other than a hash" do
- lambda {@request.headers = :foo}.should raise_error(ArgumentError)
+ expect {@request.headers = :foo}.to raise_error(ArgumentError)
end
end
@@ -75,11 +75,11 @@ describe Patron::Request do
describe :buffer_size do
it "should raise an exception when assigned a negative number" do
- lambda {@request.buffer_size = -1}.should raise_error(ArgumentError)
+ expect {@request.buffer_size = -1}.to raise_error(ArgumentError)
end
it "should raise an exception when assigned 0" do
- lambda {@request.buffer_size = 0}.should raise_error(ArgumentError)
+ expect {@request.buffer_size = 0}.to raise_error(ArgumentError)
end
end
@@ -87,18 +87,18 @@ describe Patron::Request do
describe :eql? do
it "should return true when two requests are equal" do
- @request.should eql(Patron::Request.new)
+ expect(@request).to eql(Patron::Request.new)
end
it "should return false when two requests are not equal" do
req = Patron::Request.new
req.action = :post
- @request.should_not eql(req)
+ expect(@request).not_to eql(req)
end
end
it "should be able to serialize and deserialize itself" do
- Marshal.load(Marshal.dump(@request)).should eql(@request)
+ expect(Marshal.load(Marshal.dump(@request))).to eql(@request)
end
end
diff --git a/spec/response_spec.rb b/spec/response_spec.rb
index bb240c3..e64320d 100644
--- a/spec/response_spec.rb
+++ b/spec/response_spec.rb
@@ -35,28 +35,28 @@ describe Patron::Response do
it "should strip extra spaces from header values" do
response = @session.get("/test")
# All digits, no spaces
- response.headers['Content-Length'].should match(/^\d+$/)
+ expect(response.headers['Content-Length']).to match(/^\d+$/)
end
it "should return an array of values when multiple header fields have same name" do
response = @session.get("/repetitiveheader")
- response.headers['Set-Cookie'].should == ["a=1","b=2"]
+ expect(response.headers['Set-Cookie']).to be == ["a=1","b=2"]
end
it "should works with non-text files" do
response = @session.get("/picture")
- response.headers['Content-Type'].should == 'image/png'
- response.body.encoding.should == Encoding::ASCII_8BIT
+ expect(response.headers['Content-Type']).to be == 'image/png'
+ expect(response.body.encoding).to be == Encoding::ASCII_8BIT
end
it "should not allow a default charset to be nil" do
- Encoding.stub(:default_internal).and_return("UTF-8")
+ allow(Encoding).to receive(:default_internal).and_return("UTF-8")
expect {
Patron::Response.new("url", "status", 0, "", "", nil)
}.to_not raise_error
end
it "should be able to serialize and deserialize itself" do
- Marshal.load(Marshal.dump(@request)).should eql(@request)
+ expect(Marshal.load(Marshal.dump(@request))).to eql(@request)
end
end
diff --git a/spec/session_spec.rb b/spec/session_spec.rb
index 5ae0046..0a55543 100644
--- a/spec/session_spec.rb
+++ b/spec/session_spec.rb
@@ -34,207 +34,218 @@ describe Patron::Session do
@session.base_url = "http://localhost:9001"
end
+ it "should work when forcing ipv4" do
+ @session.force_ipv4 = true
+ expect { @session.get("/test") }.to_not raise_error
+ end
+
it "should escape and unescape strings symetrically" do
string = "foo~bar baz/"
escaped = @session.escape(string)
unescaped = @session.unescape(escaped)
- unescaped.should == string
+ expect(unescaped).to be == string
end
it "should raise an error when passed an invalid action" do
- lambda { @session.request(:bogus, "/test", {}) }.should raise_error(ArgumentError)
+ expect { @session.request(:bogus, "/test", {}) }.to raise_error(ArgumentError)
end
it "should raise an error when no URL is provided" do
@session.base_url = nil
- lambda {@session.get(nil)}.should raise_error(ArgumentError)
+ expect {@session.get(nil)}.to raise_error(ArgumentError)
end
it "should retrieve a url with :get" do
response = @session.get("/test")
body = YAML::load(response.body)
- body.request_method.should == "GET"
+ expect(body.request_method).to be == "GET"
+ end
+
+ it "should use full base url" do
+ @session.base_url = "http://localhost:9001/api/v1"
+ response = @session.get("/test")
+ expect(response.url).to be == "http://localhost:9001/api/v1/test"
end
it 'should ignore #base_url when a full URL is provided' do
@session.base_url = "http://example.com:123"
- lambda { @session.get("http://localhost:9001/test") }.should_not raise_error(URI::InvalidURIError)
+ expect { @session.get("http://localhost:9001/test") }.to_not raise_error(URI::InvalidURIError)
end
it "should download content with :get and a file path" do
tmpfile = "/tmp/patron_test.yaml"
response = @session.get_file "/test", tmpfile
- response.body.should be_nil
+ expect(response.body).to be_nil
body = YAML::load_file(tmpfile)
- body.request_method.should == "GET"
+ expect(body.request_method).to be == "GET"
FileUtils.rm tmpfile
end
it "should download correctly(md5 ok) with get_file" do
tmpfile = "/tmp/picture"
response = @session.get_file "/picture", tmpfile
- response.body.should be_nil
- File.size(File.join(File.dirname(__FILE__),"../pic.png")).should == File.size(tmpfile)
+ expect(response.body).to be_nil
+ expect(File.size(File.join(File.dirname(__FILE__),"../pic.png"))).to be == File.size(tmpfile)
FileUtils.rm tmpfile
end
it "should include custom headers in a request" do
response = @session.get("/test", {"User-Agent" => "PatronTest"})
body = YAML::load(response.body)
- body.header["user-agent"].should == ["PatronTest"]
+ expect(body.header["user-agent"]).to be == ["PatronTest"]
end
it "should include default headers in a request, if they were defined" do
@session.headers = {"User-Agent" => "PatronTest"}
response = @session.get("/test")
body = YAML::load(response.body)
- body.header["user-agent"].should == ["PatronTest"]
+ expect(body.header["user-agent"]).to be == ["PatronTest"]
end
it "should merge custom headers with session headers" do
@session.headers["X-Test"] = "Testing"
response = @session.get("/test", {"User-Agent" => "PatronTest"})
body = YAML::load(response.body)
- body.header["user-agent"].should == ["PatronTest"]
- body.header["x-test"].should == ["Testing"]
+ expect(body.header["user-agent"]).to be == ["PatronTest"]
+ expect(body.header["x-test"]).to be == ["Testing"]
end
it "should raise an exception on timeout" do
@session.timeout = 1
- lambda {@session.get("/timeout")}.should raise_error(Patron::TimeoutError)
+ expect {@session.get("/timeout")}.to raise_error(Patron::TimeoutError)
end
it "should follow redirects by default" do
@session.max_redirects = 1
response = @session.get("/redirect")
body = YAML::load(response.body)
- response.status.should == 200
- body.path.should == "/test"
+ expect(response.status).to be == 200
+ expect(body.path).to be == "/test"
end
it "should include redirect count in response" do
@session.max_redirects = 1
response = @session.get("/redirect")
- response.redirect_count.should == 1
+ expect(response.redirect_count).to be == 1
end
it "should not follow redirects when configured to do so" do
@session.max_redirects = 0
response = @session.get("/redirect")
- response.status.should == 301
- response.body.should be_empty
+ expect(response.status).to be == 301
+ expect(response.body).to be_empty
end
it "should retrieve URL metadata with :head" do
response = @session.head("/test")
- response.status.should == 200
- response.body.should be_empty
- response.headers.should_not be_empty
+ expect(response.status).to be == 200
+ expect(response.body).to be_empty
+ expect(response.headers).to_not be_empty
end
it "should send a delete request with :delete" do
response = @session.delete("/test")
body = YAML::load(response.body)
- body.request_method.should == "DELETE"
+ expect(body.request_method).to be == "DELETE"
end
it "should send a COPY request with :copy" do
response = @session.copy("/test", "/test2")
body = YAML::load(response.body)
- body.request_method.should == "COPY"
+ expect(body.request_method).to be == "COPY"
end
it "should include a Destination header in COPY requests" do
response = @session.copy("/test", "/test2")
body = YAML::load(response.body)
- body.header['destination'].first.should == "/test2"
+ expect(body.header['destination'].first).to be == "/test2"
end
it "should upload data with :get" do
data = "upload data"
response = @session.request(:get, "/test", {}, :data => data)
body = YAML::load(response.body)
- body.request_method.should == "GET"
- body.header['content-length'].should == [data.size.to_s]
+ expect(body.request_method).to be == "GET"
+ expect(body.header['content-length']).to be == [data.size.to_s]
end
it "should upload data with :put" do
data = "upload data"
response = @session.put("/test", data)
body = YAML::load(response.body)
- body.request_method.should == "PUT"
- body.header['content-length'].should == [data.size.to_s]
+ expect(body.request_method).to be == "PUT"
+ expect(body.header['content-length']).to be == [data.size.to_s]
end
it "should upload data with :delete" do
data = "upload data"
response = @session.request(:delete, "/test", {}, :data => data)
body = YAML::load(response.body)
- body.request_method.should == "DELETE"
- body.header['content-length'].should == [data.size.to_s]
+ expect(body.request_method).to be == "DELETE"
+ expect(body.header['content-length']).to be == [data.size.to_s]
end
it "should raise when no data is provided to :put" do
- lambda { @session.put("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.put("/test", nil) }.to raise_error(ArgumentError)
end
it "should upload a file with :put" do
response = @session.put_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.request_method.should == "PUT"
+ expect(body.request_method).to be == "PUT"
end
it "should raise when no file is provided to :put" do
- lambda { @session.put_file("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.put_file("/test", nil) }.to raise_error(ArgumentError)
end
it "should use chunked encoding when uploading a file with :put" do
response = @session.put_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.header['transfer-encoding'].first.should == "chunked"
+ expect(body.header['transfer-encoding'].first).to be == "chunked"
end
it "should upload data with :post" do
data = "upload data"
response = @session.post("/test", data)
body = YAML::load(response.body)
- body.request_method.should == "POST"
- body.header['content-length'].should == [data.size.to_s]
+ expect(body.request_method).to be == "POST"
+ expect(body.header['content-length']).to be == [data.size.to_s]
end
it "should post a hash of arguments as a urlencoded form" do
data = {:foo => 123, 'baz' => '++hello world++'}
response = @session.post("/testpost", data)
body = YAML::load(response.body)
- body['content_type'].should == "application/x-www-form-urlencoded"
- body['body'].should match(/baz=%2B%2Bhello%20world%2B%2B/)
- body['body'].should match(/foo=123/)
+ expect(body['content_type']).to be == "application/x-www-form-urlencoded"
+ expect(body['body']).to match(/baz=%2B%2Bhello%20world%2B%2B/)
+ expect(body['body']).to match(/foo=123/)
end
it "should raise when no data is provided to :post" do
- lambda { @session.post("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.post("/test", nil) }.to raise_error(ArgumentError)
end
it "should upload a file with :post" do
response = @session.post_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.request_method.should == "POST"
+ expect(body.request_method).to be == "POST"
end
it "should upload a multipart with :post" do
response = @session.post_multipart("/test", { :test_data => "123" }, { :test_file => "LICENSE" } )
body = YAML::load(response.body)
- body.request_method.should == "POST"
+ expect(body.request_method).to be == "POST"
end
it "should raise when no file is provided to :post" do
- lambda { @session.post_file("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.post_file("/test", nil) }.to raise_error(ArgumentError)
end
it "should use chunked encoding when uploading a file with :post" do
response = @session.post_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.header['transfer-encoding'].first.should == "chunked"
+ expect(body.header['transfer-encoding'].first).to be == "chunked"
end
it "should pass credentials as http basic auth" do
@@ -242,36 +253,36 @@ describe Patron::Session do
@session.password = "bar"
response = @session.get("/test")
body = YAML::load(response.body)
- body.header['authorization'].should == [encode_authz("foo", "bar")]
+ expect(body.header['authorization']).to be == [encode_authz("foo", "bar")]
end
it "should handle cookies if set" do
@session.handle_cookies
response = @session.get("/setcookie").body
- YAML::load(response).header['cookie'].first.should == "session_id=foo123"
+ expect(YAML::load(response).header['cookie'].first).to be == "session_id=foo123"
end
it "should not handle cookies by default" do
response = @session.get("/setcookie").body
- YAML::load(response).header.should_not include('cookie')
+ expect(YAML::load(response).header).to_not include('cookie')
end
it "should ignore a wrong Content-Length when asked to" do
- lambda {
+ expect {
@session.ignore_content_length = true
@session.get("/wrongcontentlength")
- }.should_not raise_error
+ }.to_not raise_error
end
it "should fail by default with a Content-Length too high" do
- lambda {
+ expect {
@session.ignore_content_length = nil
@session.get("/wrongcontentlength")
- }.should raise_error(Patron::PartialFileError)
+ }.to raise_error(Patron::PartialFileError)
end
it "should raise exception if cookie store is not writable or readable" do
- lambda { @session.handle_cookies("/trash/clash/foo") }.should raise_error(ArgumentError)
+ expect { @session.handle_cookies("/trash/clash/foo") }.to raise_error(ArgumentError)
end
it "should work with multiple threads" do
@@ -296,42 +307,109 @@ describe Patron::Session do
body = nil
- lambda {
+ expect {
response = @session.get("/test")
body = YAML::load(response.body)
- }.should_not raise_error
+ }.to_not raise_error
- body.request_method.should == "GET"
+ expect(body.request_method).to be == "GET"
end
it "should serialize query params and append them to the url" do
response = @session.request(:get, "/test", {}, :query => {:foo => "bar"})
request = YAML::load(response.body)
request.parse
- (request.path + '?' + request.query_string).should == "/test?foo=bar"
+ expect(request.path + '?' + request.query_string).to be == "/test?foo=bar"
end
it "should merge parameters in the :query option with pre-existing query parameters" do
response = @session.request(:get, "/test?foo=bar", {}, :query => {:baz => "quux"})
request = YAML::load(response.body)
request.parse
- (request.path + '?' + request.query_string).should == "/test?foo=bar&baz=quux"
+ expect(request.path + '?' + request.query_string).to be == "/test?foo=bar&baz=quux"
end
def encode_authz(user, passwd)
"Basic " + Base64.encode64("#{user}:#{passwd}").strip
end
+ describe 'when instantiating with hash arguments' do
+
+ let(:args) { {
+ :timeout => 10,
+ :base_url => 'http://localhost:9001',
+ :headers => {'User-Agent' => 'myapp/1.0'}
+ } }
+
+ let(:session) { Patron::Session.new(args) }
+
+ it 'sets the base_url' do
+ expect(session.base_url).to be == args[:base_url]
+ end
+
+ it 'sets timeout' do
+ expect(session.timeout).to be == args[:timeout]
+ end
+
+ it 'sets headers' do
+ expect(session.headers).to be == args[:headers]
+ end
+
+ context 'when given an incorrect accessor name' do
+ let(:args) { { :not_a_real_accessor => 'http://localhost:9001' }}
+ it 'raises no method error' do
+ expect { session }.to raise_error NoMethodError
+ end
+ end
+
+ end
+
+ describe 'when instantiating with a block' do
+ args = {
+ :timeout => 10,
+ :base_url => 'http://localhost:9001',
+ :headers => {'User-Agent' => 'myapp/1.0'}
+ }
+
+ session = Patron::Session.new do |patron|
+ patron.timeout = args[:timeout]
+ patron.base_url = args[:base_url]
+ patron.headers = args[:headers]
+ end
+
+ it 'sets the base_url' do
+ expect(session.base_url).to be == args[:base_url]
+ end
+
+ it 'sets timeout' do
+ expect(session.timeout).to be == args[:timeout]
+ end
+
+ it 'sets headers' do
+ expect(session.headers).to be == args[:headers]
+ end
+
+ context 'when given an incorrect accessor name' do
+ it 'raises no method error' do
+ expect {
+ Patron::Session.new do |patron|
+ patron.timeoutttt = args[:timeout]
+ end
+ }.to raise_error NoMethodError
+ end
+ end
+ end
+
# ------------------------------------------------------------------------
describe 'when debug is enabled' do
it 'it should not clobber stderr' do
rdev = STDERR.stat.rdev
@session.enable_debug
- STDERR.stat.rdev.should be == rdev
+ expect(STDERR.stat.rdev).to be == rdev
@session.enable_debug
- STDERR.stat.rdev.should be == rdev
+ expect(STDERR.stat.rdev).to be == rdev
end
end
diff --git a/spec/session_ssl_spec.rb b/spec/session_ssl_spec.rb
index 8416415..13cb16f 100644
--- a/spec/session_ssl_spec.rb
+++ b/spec/session_ssl_spec.rb
@@ -38,197 +38,197 @@ describe Patron::Session do
it "should retrieve a url with :get" do
response = @session.get("/test")
body = YAML::load(response.body)
- body.request_method.should == "GET"
+ expect(body.request_method).to be == "GET"
end
it "should download content with :get and a file path" do
tmpfile = "/tmp/patron_test.yaml"
response = @session.get_file "/test", tmpfile
- response.body.should be_nil
+ expect(response.body).to be_nil
body = YAML::load_file(tmpfile)
- body.request_method.should == "GET"
+ expect(body.request_method).to be == "GET"
FileUtils.rm tmpfile
end
it "should download correctly(md5 ok) with get_file" do
tmpfile = "/tmp/picture"
response = @session.get_file "/picture", tmpfile
- response.body.should be_nil
- File.size(File.join(File.dirname(__FILE__),"../pic.png")).should == File.size(tmpfile)
+ expect(response.body).to be_nil
+ expect(File.size(File.join(File.dirname(__FILE__),"../pic.png"))).to be == File.size(tmpfile)
FileUtils.rm tmpfile
end
it "should include custom headers in a request" do
response = @session.get("/test", {"User-Agent" => "PatronTest"})
body = YAML::load(response.body)
- body.header["user-agent"].should == ["PatronTest"]
+ expect(body.header["user-agent"]).to be == ["PatronTest"]
end
it "should merge custom headers with session headers" do
@session.headers["X-Test"] = "Testing"
response = @session.get("/test", {"User-Agent" => "PatronTest"})
body = YAML::load(response.body)
- body.header["user-agent"].should == ["PatronTest"]
- body.header["x-test"].should == ["Testing"]
+ expect(body.header["user-agent"]).to be == ["PatronTest"]
+ expect(body.header["x-test"]).to be == ["Testing"]
end
it "should raise an exception on timeout" do
@session.timeout = 1
- lambda {@session.get("/timeout")}.should raise_error(Patron::TimeoutError)
+ expect {@session.get("/timeout")}.to raise_error(Patron::TimeoutError)
end
it "should follow redirects by default" do
@session.max_redirects = 1
response = @session.get("/redirect")
body = YAML::load(response.body)
- response.status.should == 200
- body.path.should == "/test"
+ expect(response.status).to be == 200
+ expect(body.path).to be == "/test"
end
it "should include redirect count in response" do
@session.max_redirects = 1
response = @session.get("/redirect")
- response.redirect_count.should == 1
+ expect(response.redirect_count).to be == 1
end
it "should not follow redirects when configured to do so" do
@session.max_redirects = 0
response = @session.get("/redirect")
- response.status.should == 301
- response.body.should be_empty
+ expect(response.status).to be == 301
+ expect(response.body).to be_empty
end
it "should retrieve URL metadata with :head" do
response = @session.head("/test")
- response.status.should == 200
- response.body.should be_empty
- response.headers.should_not be_empty
+ expect(response.status).to be == 200
+ expect(response.body).to be_empty
+ expect(response.headers).to_not be_empty
end
it "should send a delete request with :delete" do
response = @session.delete("/test")
body = YAML::load(response.body)
- body.request_method.should == "DELETE"
+ expect(body.request_method).to be == "DELETE"
end
it "should send a COPY request with :copy" do
response = @session.copy("/test", "/test2")
body = YAML::load(response.body)
- body.request_method.should == "COPY"
+ expect(body.request_method).to be == "COPY"
end
it "should include a Destination header in COPY requests" do
response = @session.copy("/test", "/test2")
body = YAML::load(response.body)
- body.header['destination'].first.should == "/test2"
+ expect(body.header['destination'].first).to be == "/test2"
end
it "should upload data with :get" do
data = "upload data"
response = @session.request(:get, "/test", {}, :data => data)
body = YAML::load(response.body)
- body.request_method.should == "GET"
- body.header['content-length'].should == [data.size.to_s]
+ expect(body.request_method).to be == "GET"
+ expect(body.header['content-length']).to be == [data.size.to_s]
end
it "should upload data with :put" do
data = "upload data"
response = @session.put("/test", data)
body = YAML::load(response.body)
- body.request_method.should == "PUT"
- body.header['content-length'].should == [data.size.to_s]
+ expect(body.request_method).to be == "PUT"
+ expect(body.header['content-length']).to be == [data.size.to_s]
end
it "should raise when no data is provided to :put" do
- lambda { @session.put("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.put("/test", nil) }.to raise_error(ArgumentError)
end
it "should upload a file with :put" do
response = @session.put_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.request_method.should == "PUT"
+ expect(body.request_method).to be == "PUT"
end
it "should raise when no file is provided to :put" do
- lambda { @session.put_file("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.put_file("/test", nil) }.to raise_error(ArgumentError)
end
it "should use chunked encoding when uploading a file with :put" do
response = @session.put_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.header['transfer-encoding'].first.should == "chunked"
+ expect(body.header['transfer-encoding'].first).to be == "chunked"
end
it "should upload data with :post" do
data = "upload data"
response = @session.post("/test", data)
body = YAML::load(response.body)
- body.request_method.should == "POST"
- body.header['content-length'].should == [data.size.to_s]
+ expect(body.request_method).to be == "POST"
+ expect(body.header['content-length']).to be == [data.size.to_s]
end
it "should post a hash of arguments as a urlencoded form" do
data = {:foo => 123, 'baz' => '++hello world++'}
response = @session.post("/testpost", data)
body = YAML::load(response.body)
- body['content_type'].should == "application/x-www-form-urlencoded"
- body['body'].should match(/baz=%2B%2Bhello%20world%2B%2B/)
- body['body'].should match(/foo=123/)
+ expect(body['content_type']).to be == "application/x-www-form-urlencoded"
+ expect(body['body']).to match(/baz=%2B%2Bhello%20world%2B%2B/)
+ expect(body['body']).to match(/foo=123/)
end
it "should raise when no data is provided to :post" do
- lambda { @session.post("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.post("/test", nil) }.to raise_error(ArgumentError)
end
it "should upload a file with :post" do
response = @session.post_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.request_method.should == "POST"
+ expect(body.request_method).to be == "POST"
end
it "should upload a multipart with :post" do
response = @session.post_multipart("/test", { :test_data => "123" }, { :test_file => "LICENSE" } )
body = YAML::load(response.body)
- body.request_method.should == "POST"
+ expect(body.request_method).to be == "POST"
end
it "should raise when no file is provided to :post" do
- lambda { @session.post_file("/test", nil) }.should raise_error(ArgumentError)
+ expect { @session.post_file("/test", nil) }.to raise_error(ArgumentError)
end
it "should use chunked encoding when uploading a file with :post" do
response = @session.post_file("/test", "LICENSE")
body = YAML::load(response.body)
- body.header['transfer-encoding'].first.should == "chunked"
+ expect(body.header['transfer-encoding'].first).to be == "chunked"
end
it "should handle cookies if set" do
@session.handle_cookies
response = @session.get("/setcookie").body
- YAML::load(response).header['cookie'].first.should == "session_id=foo123"
+ expect(YAML::load(response).header['cookie'].first).to be == "session_id=foo123"
end
it "should not handle cookies by default" do
response = @session.get("/setcookie").body
- YAML::load(response).header.should_not include('cookie')
+ expect(YAML::load(response).header).to_not include('cookie')
end
it "should ignore a wrong Content-Length when asked to" do
- lambda {
+ expect {
@session.ignore_content_length = true
@session.get("/wrongcontentlength")
- }.should_not raise_error
+ }.to_not raise_error
end
it "should fail by default with a Content-Length too high" do
- lambda {
+ expect {
@session.ignore_content_length = nil
@session.get("/wrongcontentlength")
- }.should raise_error(Patron::PartialFileError)
+ }.to raise_error(Patron::PartialFileError)
end
it "should raise exception if cookie store is not writable or readable" do
- lambda { @session.handle_cookies("/trash/clash/foo") }.should raise_error(ArgumentError)
+ expect { @session.handle_cookies("/trash/clash/foo") }.to raise_error(ArgumentError)
end
it "should work with multiple threads" do
@@ -244,12 +244,11 @@ describe Patron::Session do
threads.each {|t| t.join }
end
- xit "should fail when insecure mode is off" do
- # This spec fails, but I suspect that it is a setup problem.
- lambda {
+ it "should fail when insecure mode is off" do
+ expect {
@session.insecure = nil
response = @session.get("/test")
- }.should raise_error(Patron::Error)
+ }.to raise_error(Patron::Error)
end
it "should work when insecure mode is off but certificate is supplied" do
@@ -257,14 +256,14 @@ describe Patron::Session do
@session.cacert = 'spec/certs/cacert.pem'
response = @session.get("/test")
body = YAML::load(response.body)
- body.request_method.should == "GET"
+ expect(body.request_method).to be == "GET"
end
it "should work with different SSL versions" do
['SSLv3', 'TLSv1'].each do |version|
@session.ssl_version = version
response = @session.get("/test")
- response.status.should == 200
+ expect(response.status).to be == 200
end
end
@@ -274,10 +273,10 @@ describe Patron::Session do
rdev = STDERR.stat.rdev
@session.enable_debug
- STDERR.stat.rdev.should be == rdev
+ expect(STDERR.stat.rdev).to be == rdev
@session.enable_debug
- STDERR.stat.rdev.should be == rdev
+ expect(STDERR.stat.rdev).to be == rdev
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4da47bb..ec1edb1 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -21,7 +21,17 @@
## THE SOFTWARE.
##
## -------------------------------------------------------------------
+if ENV["COVERAGE"]
+ require 'simplecov'
+ SimpleCov.start do
+ add_filter "/spec/"
+ end
+end
+
require 'rspec'
+# Kill warnings that not raising a specific exception still allows the method
+# to fail with another exception
+RSpec::Expectations.configuration.warn_about_potential_false_positives = false
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/../ext')
diff --git a/spec/util_spec.rb b/spec/util_spec.rb
index f181f09..a6a5ba8 100644
--- a/spec/util_spec.rb
+++ b/spec/util_spec.rb
@@ -24,14 +24,14 @@
require File.expand_path("./spec") + '/spec_helper.rb'
describe Patron::Util do
-
+
describe :build_query_pairs_from_hash do
it "correctly serializes a simple hash" do
hash = {:foo => "bar", "baz" => 42}
array = Patron::Util.build_query_pairs_from_hash(hash)
- array.size.should == 2
- array.should include("foo=bar")
- array.should include("baz=42")
+ expect(array.size).to be == 2
+ expect(array).to include("foo=bar")
+ expect(array).to include("baz=42")
end
it "correctly serializes a more complex hash" do
hash = {
@@ -49,21 +49,21 @@ describe Patron::Util do
}
}
array = Patron::Util.build_query_pairs_from_hash(hash)
- array.size.should == 4
- array.should include("foo=bar")
- array.should include("baz[quux][zing][ying]=42")
- array.should include("baz[blargh][spaz]=sox")
- array.should include("baz[blargh][razz]=matazz")
+ expect(array.size).to be == 4
+ expect(array).to include("foo=bar")
+ expect(array).to include("baz[quux][zing][ying]=42")
+ expect(array).to include("baz[blargh][spaz]=sox")
+ expect(array).to include("baz[blargh][razz]=matazz")
end
end
-
+
describe :build_query_string_from_hash do
it "correctly serializes a simple hash" do
hash = {:foo => "bar", "baz" => 42}
array = Patron::Util.build_query_string_from_hash(hash).split('&')
- array.size.should == 2
- array.should include("foo=bar")
- array.should include("baz=42")
+ expect(array.size).to be == 2
+ expect(array).to include("foo=bar")
+ expect(array).to include("baz=42")
end
it "correctly serializes a more complex hash" do
hash = {
@@ -81,12 +81,12 @@ describe Patron::Util do
}
}
array = Patron::Util.build_query_string_from_hash(hash).split('&')
- array.size.should == 4
- array.should include("foo=bar")
- array.should include("baz[quux][zing][ying]=42")
- array.should include("baz[blargh][spaz]=sox")
- array.should include("baz[blargh][razz]=matazz")
+ expect(array.size).to be == 4
+ expect(array).to include("foo=bar")
+ expect(array).to include("baz[quux][zing][ying]=42")
+ expect(array).to include("baz[blargh][spaz]=sox")
+ expect(array).to include("baz[blargh][razz]=matazz")
end
end
-
-end
\ No newline at end of file
+
+end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-patron.git
More information about the Pkg-ruby-extras-commits
mailing list