mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-10-26 02:57:06 -07:00
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
112 lines
4.0 KiB
Diff
112 lines
4.0 KiB
Diff
diff --git a/spec/base.rb b/spec/base.rb
|
|
index 965a6e2..60fb86f 100644
|
|
--- a/spec/base.rb
|
|
+++ b/spec/base.rb
|
|
@@ -2,8 +2,6 @@ def is_ruby_19?
|
|
RUBY_VERSION == '1.9.1' or RUBY_VERSION == '1.9.2'
|
|
end
|
|
|
|
-Encoding.default_internal = Encoding.default_external = "ASCII-8BIT" if is_ruby_19?
|
|
-
|
|
require 'rubygems'
|
|
require 'spec'
|
|
|
|
@@ -14,3 +12,4 @@ rescue LoadError
|
|
end
|
|
|
|
require File.dirname(__FILE__) + '/../lib/restclient'
|
|
+require File.join(File.dirname(__FILE__), 'helpers', 'file_content_helper')
|
|
diff --git a/spec/helpers/file_content_helper.rb b/spec/helpers/file_content_helper.rb
|
|
new file mode 100644
|
|
index 0000000..86dd263
|
|
--- /dev/null
|
|
+++ b/spec/helpers/file_content_helper.rb
|
|
@@ -0,0 +1,3 @@
|
|
+def file_content_helper(path)
|
|
+ IO.respond_to?(:binread) ? IO.binread(path) : IO.read(path)
|
|
+end
|
|
diff --git a/spec/payload_spec.rb b/spec/payload_spec.rb
|
|
index 89ded79..c57b300 100644
|
|
--- a/spec/payload_spec.rb
|
|
+++ b/spec/payload_spec.rb
|
|
@@ -102,26 +102,28 @@ baz\r
|
|
|
|
it "should form properly separated multipart data" do
|
|
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
|
+ file_contents = file_content_helper(f.path)
|
|
m = RestClient::Payload::Multipart.new({:foo => f})
|
|
m.to_s.should == <<-EOS
|
|
--#{m.boundary}\r
|
|
Content-Disposition: form-data; name="foo"; filename="master_shake.jpg"\r
|
|
Content-Type: image/jpeg\r
|
|
\r
|
|
-#{IO.read(f.path)}\r
|
|
+#{file_contents}\r
|
|
--#{m.boundary}--\r
|
|
EOS
|
|
end
|
|
|
|
it "should ignore the name attribute when it's not set" do
|
|
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
|
+ file_contents = file_content_helper(f.path)
|
|
m = RestClient::Payload::Multipart.new({nil => f})
|
|
m.to_s.should == <<-EOS
|
|
--#{m.boundary}\r
|
|
Content-Disposition: form-data; filename="master_shake.jpg"\r
|
|
Content-Type: image/jpeg\r
|
|
\r
|
|
-#{IO.read(f.path)}\r
|
|
+#{file_contents}\r
|
|
--#{m.boundary}--\r
|
|
EOS
|
|
end
|
|
@@ -130,13 +132,14 @@ Content-Type: image/jpeg\r
|
|
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
|
f.instance_eval "def content_type; 'text/plain'; end"
|
|
f.instance_eval "def original_filename; 'foo.txt'; end"
|
|
+ file_contents = file_content_helper(f.path)
|
|
m = RestClient::Payload::Multipart.new({:foo => f})
|
|
m.to_s.should == <<-EOS
|
|
--#{m.boundary}\r
|
|
Content-Disposition: form-data; name="foo"; filename="foo.txt"\r
|
|
Content-Type: text/plain\r
|
|
\r
|
|
-#{IO.read(f.path)}\r
|
|
+#{file_contents}\r
|
|
--#{m.boundary}--\r
|
|
EOS
|
|
end
|
|
@@ -154,13 +157,14 @@ foo\r
|
|
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
|
f.instance_eval "def content_type; 'text/plain'; end"
|
|
f.instance_eval "def original_filename; 'foo.txt'; end"
|
|
+ file_contents = file_content_helper(f.path)
|
|
m = RestClient::Payload::Multipart.new({:foo => {:bar => f}})
|
|
m.to_s.should == <<-EOS
|
|
--#{m.boundary}\r
|
|
Content-Disposition: form-data; name="foo[bar]"; filename="foo.txt"\r
|
|
Content-Type: text/plain\r
|
|
\r
|
|
-#{IO.read(f.path)}\r
|
|
+#{file_contents}\r
|
|
--#{m.boundary}--\r
|
|
EOS
|
|
end
|
|
diff --git a/spec/response_spec.rb b/spec/response_spec.rb
|
|
index 840698e..d3964a8 100644
|
|
--- a/spec/response_spec.rb
|
|
+++ b/spec/response_spec.rb
|
|
@@ -90,12 +90,6 @@ describe RestClient::Response do
|
|
RestClient::Request.execute(:url => 'http://some/resource', :method => :get, :user => 'foo', :password => 'bar', :headers => {:accept => :json}).body.should == 'Foo'
|
|
end
|
|
|
|
- it "follows a redirection and keep the cookies" do
|
|
- stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Set-Cookie' => CGI::Cookie.new('Foo', 'Bar'), 'Location' => 'http://new/resource', })
|
|
- stub_request(:get, 'http://new/resource').with(:headers => {'Cookie' => 'Foo=Bar'}).to_return(:body => 'Qux')
|
|
- RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should == 'Qux'
|
|
- end
|
|
-
|
|
it "doesn't follow a 301 when the request is a post" do
|
|
net_http_res = mock('net http response', :code => 301)
|
|
response = RestClient::Response.create('abc', net_http_res, {:method => :post})
|