From 385dc65ba36d40d1503d1eba02bb23047d2f6e9e Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Tue, 8 Sep 2009 19:02:09 -0400 Subject: [PATCH 01/26] Fix headers overwritten by #process_cookies Closes gh-19 --- lib/httparty.rb | 8 +++----- spec/httparty_spec.rb | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/httparty.rb b/lib/httparty.rb index 0a6100a..11789eb 100644 --- a/lib/httparty.rb +++ b/lib/httparty.rb @@ -160,11 +160,9 @@ module HTTParty end def process_cookies(options) #:nodoc: - return unless options[:cookies] || default_cookies - options[:headers] ||= {} - options[:headers]["cookie"] = cookies.merge(options[:cookies] || {}).to_cookie_string - - options.delete(:cookies) + return unless options[:cookies] || default_cookies.any? + options[:headers] ||= headers.dup + options[:headers]["cookie"] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string end end diff --git a/spec/httparty_spec.rb b/spec/httparty_spec.rb index 95974dd..ac371ef 100644 --- a/spec/httparty_spec.rb +++ b/spec/httparty_spec.rb @@ -51,15 +51,53 @@ describe HTTParty do end describe "headers" do + def expect_headers(header={}) + HTTParty::Request.should_receive(:new) \ + .with(anything, anything, hash_including({ :headers => header })) \ + .and_return(mock("mock response", :perform => nil)) + end + it "should default to empty hash" do @klass.headers.should == {} end - + it "should be able to be updated" do init_headers = {:foo => 'bar', :baz => 'spax'} @klass.headers init_headers @klass.headers.should == init_headers end + + it "uses the class headers when sending a request" do + expect_headers(:foo => 'bar') + @klass.headers(:foo => 'bar') + @klass.get('') + end + + it "overwrites class headers when passing in headers" do + expect_headers(:baz => 'spax') + @klass.headers(:foo => 'bar') + @klass.get('', :headers => {:baz => 'spax'}) + end + + context "with cookies" do + it 'utilizes the class-level cookies' do + expect_headers(:foo => 'bar', 'cookie' => 'type=snickerdoodle') + @klass.headers(:foo => 'bar') + @klass.cookies(:type => 'snickerdoodle') + @klass.get('') + end + + it 'adds cookies to the headers' do + expect_headers(:foo => 'bar', 'cookie' => 'type=snickerdoodle') + @klass.headers(:foo => 'bar') + @klass.get('', :cookies => {:type => 'snickerdoodle'}) + end + + it 'adds optional cookies to the optional headers' do + expect_headers(:baz => 'spax', 'cookie' => 'type=snickerdoodle') + @klass.get('', :cookies => {:type => 'snickerdoodle'}, :headers => {:baz => 'spax'}) + end + end end describe "cookies" do From 7461fe87b74efc8f11047a444f10629a790ad701 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Tue, 8 Sep 2009 21:40:21 -0400 Subject: [PATCH 02/26] Change Rakefile to Unix format --- Rakefile | 97 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/Rakefile b/Rakefile index 6580830..62d8f75 100644 --- a/Rakefile +++ b/Rakefile @@ -1,48 +1,49 @@ -ProjectName = 'httparty' -WebsitePath = "jnunemaker@rubyforge.org:/var/www/gforge-projects/#{ProjectName}" - -require 'rubygems' -require 'rake' -require 'echoe' -require 'spec/rake/spectask' -require "lib/#{ProjectName}/version" -require 'cucumber/rake/task' - -Echoe.new(ProjectName, HTTParty::Version) do |p| - p.description = "Makes http fun! Also, makes consuming restful web services dead easy." - p.install_message = "When you HTTParty, you must party hard!" - p.url = "http://#{ProjectName}.rubyforge.org" - p.author = "John Nunemaker" - p.email = "nunemaker@gmail.com" - p.extra_deps = [['crack', '>= 0.1.1']] - p.need_tar_gz = false - p.docs_host = WebsitePath -end - -desc 'Upload website files to rubyforge' -task :website do - sh %{rsync -av website/ #{WebsitePath}} - Rake::Task['website_docs'].invoke -end - -task :website_docs do - Rake::Task['redocs'].invoke - sh %{rsync -av doc/ #{WebsitePath}/docs} -end - -desc 'Preps the gem for a new release' -task :prepare do - %w[manifest build_gemspec].each do |task| - Rake::Task[task].invoke - end -end - -Rake::Task[:default].prerequisites.clear -task :default => :spec -Spec::Rake::SpecTask.new do |t| - t.spec_files = FileList["spec/**/*_spec.rb"] -end - -Cucumber::Rake::Task.new(:features) do |t| - t.cucumber_opts = "--format pretty" -end +ProjectName = 'httparty' +WebsitePath = "jnunemaker@rubyforge.org:/var/www/gforge-projects/#{ProjectName}" + +require 'rubygems' +require 'rake' +require 'echoe' +require 'spec/rake/spectask' +require "lib/#{ProjectName}/version" +require 'cucumber/rake/task' + +Echoe.new(ProjectName, HTTParty::Version) do |p| + p.description = "Makes http fun! Also, makes consuming restful web services dead easy." + p.install_message = "When you HTTParty, you must party hard!" + p.url = "http://#{ProjectName}.rubyforge.org" + p.author = "John Nunemaker" + p.email = "nunemaker@gmail.com" + p.extra_deps = [['crack', '>= 0.1.1']] + p.need_tar_gz = false + p.docs_host = WebsitePath +end + +desc 'Upload website files to rubyforge' +task :website do + sh %{rsync -av website/ #{WebsitePath}} + Rake::Task['website_docs'].invoke +end + +task :website_docs do + Rake::Task['redocs'].invoke + sh %{rsync -av doc/ #{WebsitePath}/docs} +end + +desc 'Preps the gem for a new release' +task :prepare do + %w[manifest build_gemspec].each do |task| + Rake::Task[task].invoke + end +end + +Rake::Task[:default].prerequisites.clear +task :default => :spec +Spec::Rake::SpecTask.new do |t| + t.spec_files = FileList["spec/**/*_spec.rb"] + t.spec_opts = ['--options', 'spec/spec.opts'] +end + +Cucumber::Rake::Task.new(:features) do |t| + t.cucumber_opts = "--format pretty" +end From 7cbb1a0f79570372012ae5ffa82949bd6baec971 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Tue, 8 Sep 2009 21:40:41 -0400 Subject: [PATCH 03/26] Use specdoc in spec options --- spec/spec.opts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/spec.opts b/spec/spec.opts index 7113a85..5779d62 100644 --- a/spec/spec.opts +++ b/spec/spec.opts @@ -1,3 +1,2 @@ ---format - progress --colour +--format specdoc From 1214bb0e4baf6904b5f9991f687b56c5d078db88 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Tue, 8 Sep 2009 21:41:13 -0400 Subject: [PATCH 04/26] Update the way we load rspec --- spec/spec_helper.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c54b973..d013186 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,6 @@ -require 'rubygems' -gem 'rspec', '>= 1.2.8' -require 'spec' require File.join(File.dirname(__FILE__), '..', 'lib', 'httparty') +gem 'rspec', '>= 1.2.8' +require 'spec/autorun' def file_fixture(filename) open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read @@ -18,4 +17,4 @@ def stub_http_response_with(filename) http_request.stub!(:perform_actual_request).and_return(response) HTTParty::Request.should_receive(:new).and_return(http_request) -end \ No newline at end of file +end From 26f0391285530b49eac5d491bc357df9c6b0b418 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Tue, 8 Sep 2009 22:52:54 -0400 Subject: [PATCH 05/26] Update History --- History | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History b/History index 2d2d731..fa541f2 100644 --- a/History +++ b/History @@ -1,3 +1,7 @@ +== 0.4.5 master +* bug fixes + * Fixed class-level headers overwritten by cookie management code. Closes #19 + == 0.4.4 2009-07-19 * 2 minor update * :query no longer sets form data. Use body and set content type to application/x-www-form-urlencoded if you need it. :query was wrong for that. From 3071d23d88d12580241ecf5d184ffbe247bb91ff Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:23:28 -0400 Subject: [PATCH 06/26] Version bump to 0.0.0 --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.0 From 8c59ef5079cde371392cbcac668ef6df3cf1b91c Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:25:04 -0400 Subject: [PATCH 07/26] Updated to jeweler. yay! --- Rakefile | 102 +++++++++++++++++++++++++++++++++---------------------- VERSION | 2 +- 2 files changed, 62 insertions(+), 42 deletions(-) diff --git a/Rakefile b/Rakefile index 62d8f75..541952f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,49 +1,69 @@ -ProjectName = 'httparty' -WebsitePath = "jnunemaker@rubyforge.org:/var/www/gforge-projects/#{ProjectName}" - require 'rubygems' require 'rake' -require 'echoe' -require 'spec/rake/spectask' -require "lib/#{ProjectName}/version" -require 'cucumber/rake/task' -Echoe.new(ProjectName, HTTParty::Version) do |p| - p.description = "Makes http fun! Also, makes consuming restful web services dead easy." - p.install_message = "When you HTTParty, you must party hard!" - p.url = "http://#{ProjectName}.rubyforge.org" - p.author = "John Nunemaker" - p.email = "nunemaker@gmail.com" - p.extra_deps = [['crack', '>= 0.1.1']] - p.need_tar_gz = false - p.docs_host = WebsitePath +begin + require 'jeweler' + Jeweler::Tasks.new do |gem| + gem.name = "httparty" + gem.description = %Q{Makes http fun! Also, makes consuming restful web services dead easy.} + gem.email = "nunemaker@gmail.com" + gem.homepage = "http://httparty.rubyforge.org" + gem.authors = ["John Nunemaker"] + gem.add_dependency 'crack', '>= 0.1.1' + gem.add_development_dependency "rspec" + gem.post_install_message = "When you HTTParty, you must party hard!" + # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings + end + Jeweler::RubyforgeTasks.new do |rubyforge| + rubyforge.doc_task = "rdoc" + end +rescue LoadError + puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" +end + +require 'spec/rake/spectask' +Spec::Rake::SpecTask.new(:spec) do |spec| +spec.libs << 'lib' << 'spec' +spec.spec_files = FileList['spec/**/*_spec.rb'] +spec.spec_opts = ['--options', 'spec/spec.opts'] +end + +Spec::Rake::SpecTask.new(:rcov) do |spec| +spec.libs << 'lib' << 'spec' +spec.pattern = 'spec/**/*_spec.rb' +spec.rcov = true +end + +task :spec => :check_dependencies + +begin + require 'cucumber/rake/task' + Cucumber::Rake::Task.new(:features) + + task :features => :check_dependencies +rescue LoadError + task :features do + abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber" + end +end + +task :default => [:spec, :features] + +require 'rake/rdoctask' +Rake::RDocTask.new do |rdoc| +if File.exist?('VERSION') + version = File.read('VERSION') +else + version = "" +end + +rdoc.rdoc_dir = 'rdoc' +rdoc.title = "httparty #{version}" +rdoc.rdoc_files.include('README*') +rdoc.rdoc_files.include('lib/**/*.rb') end desc 'Upload website files to rubyforge' task :website do - sh %{rsync -av website/ #{WebsitePath}} - Rake::Task['website_docs'].invoke -end - -task :website_docs do - Rake::Task['redocs'].invoke - sh %{rsync -av doc/ #{WebsitePath}/docs} -end - -desc 'Preps the gem for a new release' -task :prepare do - %w[manifest build_gemspec].each do |task| - Rake::Task[task].invoke - end -end - -Rake::Task[:default].prerequisites.clear -task :default => :spec -Spec::Rake::SpecTask.new do |t| - t.spec_files = FileList["spec/**/*_spec.rb"] - t.spec_opts = ['--options', 'spec/spec.opts'] -end - -Cucumber::Rake::Task.new(:features) do |t| - t.cucumber_opts = "--format pretty" +sh %{rsync -av website/ jnunemaker@rubyforge.org:/var/www/gforge-projects/httparty} end diff --git a/VERSION b/VERSION index 77d6f4c..6f2743d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.0 +0.4.4 From e922314ea2ed9bcfb4ff1722656030f7e10949aa Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:25:14 -0400 Subject: [PATCH 08/26] Updated website to point to github issues instead of lighthouse. --- website/index.html | 71 +++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/website/index.html b/website/index.html index 79ce7b7..3b4c86f 100644 --- a/website/index.html +++ b/website/index.html @@ -1,32 +1,31 @@ - - HTTParty by John Nunemaker - + + HTTParty by John Nunemaker +
- - -
-

Install

-
$ sudo gem install httparty
- -

Some Quick Examples

- -

The following is a simple example of wrapping Twitter's API for posting updates.

+ + +
+

Install

+
$ sudo gem install httparty
+ +

Some Quick Examples

+ +

The following is a simple example of wrapping Twitter's API for posting updates.

class Twitter
   include HTTParty
@@ -36,9 +35,9 @@ end
 
 Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty and everyone is invited!"})
-

That is really it! The object returned is a ruby hash that is decoded from Twitter's json response. JSON parsing is used because of the .json extension in the path of the request. You can also explicitly set a format (see the examples).

+

That is really it! The object returned is a ruby hash that is decoded from Twitter's json response. JSON parsing is used because of the .json extension in the path of the request. You can also explicitly set a format (see the examples).

-

That works and all but what if you don't want to embed your username and password in the class? Below is an example to fix that:

+

That works and all but what if you don't want to embed your username and password in the class? Below is an example to fix that:

class Twitter
   include HTTParty
@@ -55,19 +54,19 @@ Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty an
 end
 
 Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")
- -

More Examples: There are several examples in the gem itself.

- -

Support

-

Conversations welcome in the google group and bugs/features over at Lightouse.

- - -
+ +

More Examples: There are several examples in the gem itself.

+ +

Support

+

Conversations welcome in the google group and bugs/features over at Github.

+ + +
- +
From f2fa3ce13b9b6dada531feb8a00cf43b11573197 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:26:42 -0400 Subject: [PATCH 09/26] Added version to gem requirement of crack. --- lib/httparty.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/httparty.rb b/lib/httparty.rb index 11789eb..a7fbd90 100644 --- a/lib/httparty.rb +++ b/lib/httparty.rb @@ -4,7 +4,7 @@ require 'net/http' require 'net/https' require 'httparty/module_inheritable_attributes' require 'rubygems' -gem 'crack' +gem 'crack', '>= 0.1.1' require 'crack' require 'httparty/cookie_hash' From 4eb14a17ba94856053b7e11ae6488b1a331c7e91 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:30:53 -0400 Subject: [PATCH 10/26] Switched from BlankSlate to BasicObject and only defining it if it doesn't exist for ruby 1.9 compat. Closes gh-20 --- lib/httparty/core_extensions.rb | 10 +++------- lib/httparty/response.rb | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/httparty/core_extensions.rb b/lib/httparty/core_extensions.rb index 948411d..fcf33ea 100644 --- a/lib/httparty/core_extensions.rb +++ b/lib/httparty/core_extensions.rb @@ -1,10 +1,6 @@ -if RUBY_VERSION.to_f == 1.8 - class BlankSlate #:nodoc: - instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval|object_id/ } - end -else - class BlankSlate < BasicObject; end -end +class BasicObject #:nodoc: + instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval/ } +end unless defined?(BasicObject) # 1.8.6 has mistyping of transitive in if statement require "rexml/document" diff --git a/lib/httparty/response.rb b/lib/httparty/response.rb index 2670b51..83529db 100644 --- a/lib/httparty/response.rb +++ b/lib/httparty/response.rb @@ -1,5 +1,5 @@ module HTTParty - class Response < BlankSlate #:nodoc: + class Response < BasicObject #:nodoc: attr_accessor :body, :code, :message, :headers attr_reader :delegate From a92d14ebca1dabcabc97fe85bf88208a9cfe9eb5 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:32:09 -0400 Subject: [PATCH 11/26] Updated readme with how to build from master. --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 0533e57..f78fbc0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -6,7 +6,7 @@ Makes http fun again! Releases are tagged on github and also released as gems on github and rubyforge. Master is pushed to whenever I add a patch or a new feature. To build from master, you can clone the code, generate the updated gemspec, build the gem and install. -* rake build_gemspec +* rake gemspec * gem build httparty.gemspec * gem install the gem that was built From 20def2302193d2a159afafeb00d541c20d3fa033 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:36:24 -0400 Subject: [PATCH 12/26] Added summary so gemspec install works properly. --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 541952f..d86444c 100644 --- a/Rakefile +++ b/Rakefile @@ -5,6 +5,7 @@ begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "httparty" + gem.summary = %Q{Makes http fun! Also, makes consuming restful web services dead easy.} gem.description = %Q{Makes http fun! Also, makes consuming restful web services dead easy.} gem.email = "nunemaker@gmail.com" gem.homepage = "http://httparty.rubyforge.org" From 51f51424e1d29a404d481bfd287279e463e76bfe Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 10:36:41 -0400 Subject: [PATCH 13/26] Switched to exact requires instead of load path stuff. --- lib/httparty.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/httparty.rb b/lib/httparty.rb index a7fbd90..ab3f018 100644 --- a/lib/httparty.rb +++ b/lib/httparty.rb @@ -1,13 +1,14 @@ -$:.unshift(File.dirname(__FILE__)) - +require 'pathname' require 'net/http' require 'net/https' -require 'httparty/module_inheritable_attributes' require 'rubygems' gem 'crack', '>= 0.1.1' require 'crack' -require 'httparty/cookie_hash' +dir = Pathname(__FILE__).dirname.expand_path + +require dir + 'httparty/module_inheritable_attributes' +require dir + 'httparty/cookie_hash' module HTTParty @@ -198,7 +199,7 @@ module HTTParty end end -require 'httparty/core_extensions' -require 'httparty/exceptions' -require 'httparty/request' -require 'httparty/response' +require dir + 'httparty/core_extensions' +require dir + 'httparty/exceptions' +require dir + 'httparty/request' +require dir + 'httparty/response' From c1b15417a72fa20b2f26c1679fed1cdc47435771 Mon Sep 17 00:00:00 2001 From: James Pozdena Date: Sun, 2 Aug 2009 14:42:59 -0700 Subject: [PATCH 14/26] updating cookies with redirects --- lib/httparty/cookie_hash.rb | 19 ++++++++++-- lib/httparty/request.rb | 11 +++++++ spec/httparty/cookie_hash_spec.rb | 51 +++++++++++++++++++++++++------ spec/httparty/request_spec.rb | 27 ++++++++++++++++ 4 files changed, 96 insertions(+), 12 deletions(-) diff --git a/lib/httparty/cookie_hash.rb b/lib/httparty/cookie_hash.rb index cf18bd7..2a9dda1 100644 --- a/lib/httparty/cookie_hash.rb +++ b/lib/httparty/cookie_hash.rb @@ -1,9 +1,22 @@ class HTTParty::CookieHash < Hash #:nodoc: - def add_cookies(hash) - merge!(hash) + + CLIENT_COOKIES = %w{path expires domain path secure HTTPOnly} + + def add_cookies(value) + case value + when Hash + merge!(value) + when String + value.split('; ').each do |cookie| + array = cookie.split('=') + self[array[0].to_sym] = array[1] + end + else + raise "add_cookies only takes a Hash or a String" + end end def to_cookie_string - collect { |k, v| "#{k}=#{v}" }.join("; ") + delete_if { |k, v| CLIENT_COOKIES.include?(k.to_s) }.collect { |k, v| "#{k}=#{v}" }.join("; ") end end diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index 3298e07..745016f 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -98,6 +98,8 @@ module HTTParty options[:limit] -= 1 self.path = response['location'] @redirect = true + self.http_method = Net::HTTP::Get + capture_cookies(response) perform else parsed_response = parse_response(response.body) @@ -118,6 +120,15 @@ module HTTParty body end end + + def capture_cookies(response) + return unless response['Set-Cookie'] + cookies_hash = HTTParty::CookieHash.new() + cookies_hash.add_cookies(options[:headers]['Cookie']) if options[:headers] && options[:headers]['Cookie'] + cookies_hash.add_cookies(response['Set-Cookie']) + options[:headers] ||= {} + options[:headers]['Cookie'] = cookies_hash.to_cookie_string + end # Uses the HTTP Content-Type header to determine the format of the response # It compares the MIME type returned to the types stored in the AllowedFormats hash diff --git a/spec/httparty/cookie_hash_spec.rb b/spec/httparty/cookie_hash_spec.rb index a110003..5708020 100644 --- a/spec/httparty/cookie_hash_spec.rb +++ b/spec/httparty/cookie_hash_spec.rb @@ -6,17 +6,44 @@ describe HTTParty::CookieHash do end describe "#add_cookies" do - it "should add new key/value pairs to the hash" do - @cookie_hash.add_cookies(:foo => "bar") - @cookie_hash.add_cookies(:rofl => "copter") - @cookie_hash.length.should eql(2) + + describe "with a hash" do + it "should add new key/value pairs to the hash" do + @cookie_hash.add_cookies(:foo => "bar") + @cookie_hash.add_cookies(:rofl => "copter") + @cookie_hash.length.should eql(2) + end + + it "should overwrite any existing key" do + @cookie_hash.add_cookies(:foo => "bar") + @cookie_hash.add_cookies(:foo => "copter") + @cookie_hash.length.should eql(1) + @cookie_hash[:foo].should eql("copter") + end end - it "should overwrite any existing key" do - @cookie_hash.add_cookies(:foo => "bar") - @cookie_hash.add_cookies(:foo => "copter") - @cookie_hash.length.should eql(1) - @cookie_hash[:foo].should eql("copter") + describe "with a string" do + it "should add new key/value pairs to the hash" do + @cookie_hash.add_cookies("first=one; second=two; third") + @cookie_hash[:first].should == 'one' + @cookie_hash[:second].should == 'two' + @cookie_hash[:third].should == nil + end + + it "should overwrite any existing key" do + @cookie_hash[:foo] = 'bar' + @cookie_hash.add_cookies("foo=tar") + @cookie_hash.length.should eql(1) + @cookie_hash[:foo].should eql("tar") + end + end + + describe 'with other class' do + it "should error" do + lambda { + @cookie_hash.add_cookies(Array.new) + }.should raise_error + end end end @@ -34,5 +61,11 @@ describe HTTParty::CookieHash do @s.should match(/rofl=copter/) @s.should match(/^\w+=\w+; \w+=\w+$/) end + + it "should not include client side only cookies" do + @cookie_hash.add_cookies(:path => "/") + @s = @cookie_hash.to_cookie_string + @s.should_not match(/path=\//) + end end end diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index a367053..2961010 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -176,6 +176,33 @@ describe HTTParty::Request do @request.http_method = Net::HTTP::Put @request.perform.should == {"hash" => {"foo" => "bar"}} end + + it "should keep track of cookies between redirects" do + @redirect['Set-Cookie'] = 'foo=bar; name=value; HTTPOnly' + @request.perform + @request.options[:headers]['Cookie'].should match(/foo=bar/) + @request.options[:headers]['Cookie'].should match(/name=value/) + end + + it 'should update cookies with rediects' do + @request.options[:headers] = {'Cookie'=> 'foo=bar;'} + @redirect['Set-Cookie'] = 'foo=tar;' + @request.perform + @request.options[:headers]['Cookie'].should match(/foo=tar/) + end + + it 'should keep cookies between rediects' do + @request.options[:headers] = {'Cookie'=> 'keep=me'} + @redirect['Set-Cookie'] = 'foo=tar;' + @request.perform + @request.options[:headers]['Cookie'].should match(/keep=me/) + end + + it 'should make resulting request a get request if it not already' do + @request.http_method = Net::HTTP::Delete + @request.perform.should == {"hash" => {"foo" => "bar"}} + @request.http_method.should == Net::HTTP::Get + end end describe "infinitely" do From 6f12a866a03d6e6473b59680bfe6cb76bb28caf9 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 22 Aug 2009 21:14:32 -0400 Subject: [PATCH 15/26] Added fakeweb to make sure no external requests get out. --- spec/spec_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d013186..d51eaaf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,10 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'httparty') gem 'rspec', '>= 1.2.8' +gem 'fakeweb' require 'spec/autorun' +require 'fakeweb' + +FakeWeb.allow_net_connect = false def file_fixture(filename) open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read From dde6ec50ff2753b55bdc83e1f8c3865b3d286413 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Wed, 9 Sep 2009 00:11:05 -0400 Subject: [PATCH 16/26] Update History --- History | 3 +++ 1 file changed, 3 insertions(+) diff --git a/History b/History index fa541f2..1af18cd 100644 --- a/History +++ b/History @@ -1,6 +1,9 @@ == 0.4.5 master * bug fixes * Fixed class-level headers overwritten by cookie management code. Closes #19 + * Fixed "superclass mismatch for class BlankSlate" error. Closes #20 +* minor updates + * Building gem with Jeweler == 0.4.4 2009-07-19 * 2 minor update From ddfc5ea4b9c4097b02fbad34313e90011fcc7eba Mon Sep 17 00:00:00 2001 From: Vesa Nieminen Date: Thu, 27 Aug 2009 18:32:18 +0800 Subject: [PATCH 17/26] Fixed reading file content to request body data Signed-off-by: sandro turriate --- bin/httparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/httparty b/bin/httparty index 729cc8a..933a770 100755 --- a/bin/httparty +++ b/bin/httparty @@ -37,7 +37,7 @@ OptionParser.new do |o| "--data [BODY]", "Data to put in request body (prefix with '@' for file)") do |d| if d =~ /^@/ - opts[:data] = open(d).read + opts[:data] = open(d[1..-1]).read else opts[:data] = d end From 71470294dc9cdc4394527d218cdf35d0ff6ad33e Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Thu, 10 Sep 2009 23:31:07 -0400 Subject: [PATCH 18/26] Update History --- History | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/History b/History index 1af18cd..5fb7e64 100644 --- a/History +++ b/History @@ -2,7 +2,8 @@ * bug fixes * Fixed class-level headers overwritten by cookie management code. Closes #19 * Fixed "superclass mismatch for class BlankSlate" error. Closes #20 -* minor updates + * Fixed reading files as post data from the command line (vesan) +* minor enhancements * Building gem with Jeweler == 0.4.4 2009-07-19 From 30e393142f68800febc7f4e907fbfe960d012191 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 1 May 2009 16:51:44 -0600 Subject: [PATCH 19/26] added configurable timeout option to Net::HTTP with spec test Closes gh-17 --- lib/httparty/request.rb | 12 ++++++++++++ spec/httparty/request_spec.rb | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index 745016f..9c7a051 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -41,12 +41,24 @@ module HTTParty end private + # def http + # http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport]) + # http.use_ssl = (uri.port == 443) + # http.verify_mode = OpenSSL::SSL::VERIFY_NONE + # http + # end + def http http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport]) http.use_ssl = (uri.port == 443) http.verify_mode = OpenSSL::SSL::VERIFY_NONE + if options[:timeout] && options[:timeout].is_a?(Integer) + http.open_timeout = options[:timeout] + http.read_timeout = options[:timeout] + end http end + def body options[:body].is_a?(Hash) ? options[:body].to_params : options[:body] diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index 2961010..237e9a1 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -46,6 +46,23 @@ describe HTTParty::Request do @request.send(:setup_raw_request) @request.instance_variable_get(:@raw_request)['authorization'].should_not be_nil end + + it "should change timeout when configured (if an Integer)" do + @request.send(:http).open_timeout.should be_nil + @request.send(:http).read_timeout.should == 60 + + invalid_timeout = "invalid" + invalid_timeout.is_a?(Integer).should be_false + @request.options[:timeout] = invalid_timeout + @request.send(:http).open_timeout.should be_nil + @request.send(:http).read_timeout.should == 60 + + timeout = 30 + timeout.is_a?(Integer).should be_true + @request.options[:timeout] = timeout + @request.send(:http).open_timeout.should == timeout + @request.send(:http).read_timeout.should == timeout + end end describe '#format_from_mimetype' do From 0cbdb7dfbf61e43d0cb7821883ee466061161034 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Sat, 12 Sep 2009 22:32:56 -0400 Subject: [PATCH 20/26] Cleanup timeout option specs --- lib/httparty/request.rb | 7 ------- spec/httparty/request_spec.rb | 35 ++++++++++++++++++----------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index 9c7a051..e98d208 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -41,12 +41,6 @@ module HTTParty end private - # def http - # http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport]) - # http.use_ssl = (uri.port == 443) - # http.verify_mode = OpenSSL::SSL::VERIFY_NONE - # http - # end def http http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport]) @@ -58,7 +52,6 @@ module HTTParty end http end - def body options[:body].is_a?(Hash) ? options[:body].to_params : options[:body] diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index 237e9a1..e875822 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -46,25 +46,26 @@ describe HTTParty::Request do @request.send(:setup_raw_request) @request.instance_variable_get(:@raw_request)['authorization'].should_not be_nil end - - it "should change timeout when configured (if an Integer)" do - @request.send(:http).open_timeout.should be_nil - @request.send(:http).read_timeout.should == 60 - - invalid_timeout = "invalid" - invalid_timeout.is_a?(Integer).should be_false - @request.options[:timeout] = invalid_timeout - @request.send(:http).open_timeout.should be_nil - @request.send(:http).read_timeout.should == 60 - - timeout = 30 - timeout.is_a?(Integer).should be_true - @request.options[:timeout] = timeout - @request.send(:http).open_timeout.should == timeout - @request.send(:http).read_timeout.should == timeout + + context "when setting timeout" do + it "does nothing if the timeout option is a string" do + http = mock("http", :null_object => true) + http.should_not_receive(:open_timeout=) + http.should_not_receive(:read_timeout=) + Net::HTTP.stub(:new => http) + + request = HTTParty::Request.new(Net::HTTP::Get, 'https://foobar.com', {:timeout => "five seconds"}) + request.send(:http) + end + + it "sets the timeout to 5 seconds" do + @request.options[:timeout] = 5 + @request.send(:http).open_timeout.should == 5 + @request.send(:http).read_timeout.should == 5 + end end end - + describe '#format_from_mimetype' do it 'should handle text/xml' do ["text/xml", "text/xml; charset=iso8859-1"].each do |ct| From 3c208119e37c17b182b0695bda73863f5853e63c Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Sat, 12 Sep 2009 22:32:59 -0400 Subject: [PATCH 21/26] Add cucumber feature to test timeout option --- features/steps/env.rb | 1 + features/steps/httparty_response_steps.rb | 4 ++-- features/steps/httparty_steps.rb | 8 ++++++-- features/steps/mongrel_helper.rb | 3 ++- features/steps/remote_service_steps.rb | 5 +++++ features/supports_timeout_option.feature | 12 ++++++++++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 features/supports_timeout_option.feature diff --git a/features/steps/env.rb b/features/steps/env.rb index b85c79a..c75dcec 100644 --- a/features/steps/env.rb +++ b/features/steps/env.rb @@ -8,6 +8,7 @@ Before do @host_and_port = "0.0.0.0:#{port}" @server = Mongrel::HttpServer.new("0.0.0.0", port) @server.run + @request_options = {} end After do diff --git a/features/steps/httparty_response_steps.rb b/features/steps/httparty_response_steps.rb index f210cc6..684d0f5 100644 --- a/features/steps/httparty_response_steps.rb +++ b/features/steps/httparty_response_steps.rb @@ -20,7 +20,7 @@ Then /it should return a response with a (\d+) response code/ do |code| @response_from_httparty.code.should eql(code.to_i) end -Then /it should raise an HTTParty::RedirectionTooDeep exception/ do +Then /it should raise (?:an|a) ([\w:]+) exception/ do |exception| @exception_from_httparty.should_not be_nil - @exception_from_httparty.class.should eql(HTTParty::RedirectionTooDeep) + @exception_from_httparty.class.name.should eql(exception) end diff --git a/features/steps/httparty_steps.rb b/features/steps/httparty_steps.rb index 17c63dd..3a82c78 100644 --- a/features/steps/httparty_steps.rb +++ b/features/steps/httparty_steps.rb @@ -1,7 +1,11 @@ +When /^I set my HTTParty timeout option to (\d+)$/ do |timeout| + @request_options[:timeout] = timeout.to_i +end + When /I call HTTParty#get with '(.*)'$/ do |url| begin - @response_from_httparty = HTTParty.get("http://#{@host_and_port}#{url}") - rescue HTTParty::RedirectionTooDeep => e + @response_from_httparty = HTTParty.get("http://#{@host_and_port}#{url}", @request_options) + rescue HTTParty::RedirectionTooDeep, Timeout::Error => e @exception_from_httparty = e end end diff --git a/features/steps/mongrel_helper.rb b/features/steps/mongrel_helper.rb index 3b78248..80b8d8c 100644 --- a/features/steps/mongrel_helper.rb +++ b/features/steps/mongrel_helper.rb @@ -1,6 +1,6 @@ def basic_mongrel_handler Class.new(Mongrel::HttpHandler) do - attr_writer :content_type, :response_body, :response_code + attr_writer :content_type, :response_body, :response_code, :preprocessor def initialize @content_type = "text/html" @@ -10,6 +10,7 @@ def basic_mongrel_handler end def process(request, response) + instance_eval &@preprocessor if @preprocessor reply_with(response, @response_code, @response_body) end diff --git a/features/steps/remote_service_steps.rb b/features/steps/remote_service_steps.rb index 08e205c..c806246 100644 --- a/features/steps/remote_service_steps.rb +++ b/features/steps/remote_service_steps.rb @@ -12,6 +12,11 @@ Given /that service is accessed at the path '(.*)'/ do |path| @server.register(path, @handler) end +Given /^that service takes (\d+) seconds to generate a response$/ do |time| + preprocessor = lambda { sleep time.to_i } + @handler.preprocessor = preprocessor +end + Given /the response from the service has a Content-Type of '(.*)'/ do |content_type| @handler.content_type = content_type end diff --git a/features/supports_timeout_option.feature b/features/supports_timeout_option.feature new file mode 100644 index 0000000..aab5f5b --- /dev/null +++ b/features/supports_timeout_option.feature @@ -0,0 +1,12 @@ +Feature: Supports the timeout option + In order to handle inappropriately slow response times + As a developer + I want my request to raise an exception after my specified timeout as elapsed + + Scenario: A long running response + Given a remote service that returns '

Some HTML

' + And that service is accessed at the path '/service.html' + And that service takes 2 seconds to generate a response + When I set my HTTParty timeout option to 1 + And I call HTTParty#get with '/service.html' + Then it should raise a Timeout::Error exception From 358abf6d8c6e1b2f9c9fe55d35b5bf0b78bcd3bb Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Sat, 12 Sep 2009 22:43:56 -0400 Subject: [PATCH 22/26] Update History --- History | 2 ++ 1 file changed, 2 insertions(+) diff --git a/History b/History index 5fb7e64..cb1a4d3 100644 --- a/History +++ b/History @@ -4,6 +4,8 @@ * Fixed "superclass mismatch for class BlankSlate" error. Closes #20 * Fixed reading files as post data from the command line (vesan) * minor enhancements + * Timeout option added; will raise a Timeout::Error after the timeout has elapsed (attack). Closes #17 + HTTParty.get "http://github.com", :timeout => 1 * Building gem with Jeweler == 0.4.4 2009-07-19 From fe529f9eb94444eee152ad3c37836f709d027e57 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Sat, 12 Sep 2009 22:52:43 -0400 Subject: [PATCH 23/26] Specify version for rspec developer dependency --- Rakefile | 2 +- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index d86444c..c51f2bf 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ begin gem.homepage = "http://httparty.rubyforge.org" gem.authors = ["John Nunemaker"] gem.add_dependency 'crack', '>= 0.1.1' - gem.add_development_dependency "rspec" + gem.add_development_dependency "rspec", "1.2.8" gem.post_install_message = "When you HTTParty, you must party hard!" # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d51eaaf..fdb1553 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'httparty') -gem 'rspec', '>= 1.2.8' +gem 'rspec', '1.2.8' gem 'fakeweb' require 'spec/autorun' require 'fakeweb' From 9fbdf8fa406c4bd3fff97a21c82f5c92cf35eb6a Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Sat, 12 Sep 2009 23:13:19 -0400 Subject: [PATCH 24/26] Update History --- History | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/History b/History index cb1a4d3..b421c43 100644 --- a/History +++ b/History @@ -1,4 +1,4 @@ -== 0.4.5 master +== 0.4.5 2009-09-12 * bug fixes * Fixed class-level headers overwritten by cookie management code. Closes #19 * Fixed "superclass mismatch for class BlankSlate" error. Closes #20 From 3ccb850cabaf3eeb8665e1f9477c9036ca0978f0 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Sat, 12 Sep 2009 23:13:24 -0400 Subject: [PATCH 25/26] Version bump to 0.4.5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6f2743d..0bfccb0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.4 +0.4.5 From 7443e42395e00ddaee362586471ae948eada4a76 Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Sat, 12 Sep 2009 23:14:01 -0400 Subject: [PATCH 26/26] Regenerated gemspec for version 0.4.5 --- httparty.gemspec | 89 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/httparty.gemspec b/httparty.gemspec index d522dd7..9a6190f 100644 --- a/httparty.gemspec +++ b/httparty.gemspec @@ -1,26 +1,95 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE +# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec` # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{httparty} - s.version = "0.4.4" + s.version = "0.4.5" - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["John Nunemaker"] - s.date = %q{2009-07-19} + s.date = %q{2009-09-12} s.default_executable = %q{httparty} s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.} s.email = %q{nunemaker@gmail.com} s.executables = ["httparty"] - s.extra_rdoc_files = ["bin/httparty", "lib/httparty/cookie_hash.rb", "lib/httparty/core_extensions.rb", "lib/httparty/exceptions.rb", "lib/httparty/module_inheritable_attributes.rb", "lib/httparty/request.rb", "lib/httparty/response.rb", "lib/httparty/version.rb", "lib/httparty.rb", "README.rdoc"] - s.files = ["bin/httparty", "cucumber.yml", "examples/aaws.rb", "examples/basic.rb", "examples/delicious.rb", "examples/google.rb", "examples/rubyurl.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "features/basic_authentication.feature", "features/command_line.feature", "features/deals_with_http_error_codes.feature", "features/handles_multiple_formats.feature", "features/steps/env.rb", "features/steps/httparty_response_steps.rb", "features/steps/httparty_steps.rb", "features/steps/mongrel_helper.rb", "features/steps/remote_service_steps.rb", "features/supports_redirection.feature", "History", "httparty.gemspec", "lib/httparty/cookie_hash.rb", "lib/httparty/core_extensions.rb", "lib/httparty/exceptions.rb", "lib/httparty/module_inheritable_attributes.rb", "lib/httparty/request.rb", "lib/httparty/response.rb", "lib/httparty/version.rb", "lib/httparty.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.rdoc", "spec/fixtures/delicious.xml", "spec/fixtures/empty.xml", "spec/fixtures/google.html", "spec/fixtures/twitter.json", "spec/fixtures/twitter.xml", "spec/fixtures/undefined_method_add_node_for_nil.xml", "spec/httparty/cookie_hash_spec.rb", "spec/httparty/request_spec.rb", "spec/httparty/response_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "website/css/common.css", "website/index.html"] + s.extra_rdoc_files = [ + "README.rdoc" + ] + s.files = [ + ".gitignore", + "History", + "MIT-LICENSE", + "Manifest", + "README.rdoc", + "Rakefile", + "VERSION", + "bin/httparty", + "cucumber.yml", + "examples/aaws.rb", + "examples/basic.rb", + "examples/delicious.rb", + "examples/google.rb", + "examples/rubyurl.rb", + "examples/twitter.rb", + "examples/whoismyrep.rb", + "features/basic_authentication.feature", + "features/command_line.feature", + "features/deals_with_http_error_codes.feature", + "features/handles_multiple_formats.feature", + "features/steps/env.rb", + "features/steps/httparty_response_steps.rb", + "features/steps/httparty_steps.rb", + "features/steps/mongrel_helper.rb", + "features/steps/remote_service_steps.rb", + "features/supports_redirection.feature", + "features/supports_timeout_option.feature", + "httparty.gemspec", + "lib/httparty.rb", + "lib/httparty/cookie_hash.rb", + "lib/httparty/core_extensions.rb", + "lib/httparty/exceptions.rb", + "lib/httparty/module_inheritable_attributes.rb", + "lib/httparty/request.rb", + "lib/httparty/response.rb", + "lib/httparty/version.rb", + "spec/fixtures/delicious.xml", + "spec/fixtures/empty.xml", + "spec/fixtures/google.html", + "spec/fixtures/twitter.json", + "spec/fixtures/twitter.xml", + "spec/fixtures/undefined_method_add_node_for_nil.xml", + "spec/httparty/cookie_hash_spec.rb", + "spec/httparty/request_spec.rb", + "spec/httparty/response_spec.rb", + "spec/httparty_spec.rb", + "spec/spec.opts", + "spec/spec_helper.rb", + "website/css/common.css", + "website/index.html" + ] s.has_rdoc = true s.homepage = %q{http://httparty.rubyforge.org} s.post_install_message = %q{When you HTTParty, you must party hard!} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Httparty", "--main", "README.rdoc"] + s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubyforge_project = %q{httparty} s.rubygems_version = %q{1.3.1} s.summary = %q{Makes http fun! Also, makes consuming restful web services dead easy.} + s.test_files = [ + "spec/httparty/cookie_hash_spec.rb", + "spec/httparty/request_spec.rb", + "spec/httparty/response_spec.rb", + "spec/httparty_spec.rb", + "spec/spec_helper.rb", + "examples/aaws.rb", + "examples/basic.rb", + "examples/delicious.rb", + "examples/google.rb", + "examples/rubyurl.rb", + "examples/twitter.rb", + "examples/whoismyrep.rb" + ] if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION @@ -28,13 +97,13 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0.1.1"]) - s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, ["= 1.2.8"]) else s.add_dependency(%q, [">= 0.1.1"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["= 1.2.8"]) end else s.add_dependency(%q, [">= 0.1.1"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["= 1.2.8"]) end end