kerryb-httparty 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/History CHANGED
@@ -1,4 +1,10 @@
1
- == 0.4.5 2009-04-23
1
+ == 0.4.4 2009-07-19
2
+ * 2 minor update
3
+ * :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.
4
+ * Fixed a bug in the cookies class method that caused cookies to be forgotten after the first request.
5
+ * Also, some general cleanup of tests and such.
6
+
7
+ == 0.4.3 2009-04-23
2
8
  * 1 minor update
3
9
  * added message to the response object
4
10
 
data/Manifest CHANGED
@@ -1,3 +1,8 @@
1
+ History
2
+ MIT-LICENSE
3
+ Manifest
4
+ README.rdoc
5
+ Rakefile
1
6
  bin/httparty
2
7
  cucumber.yml
3
8
  examples/aaws.rb
@@ -17,8 +22,8 @@ features/steps/httparty_steps.rb
17
22
  features/steps/mongrel_helper.rb
18
23
  features/steps/remote_service_steps.rb
19
24
  features/supports_redirection.feature
20
- History
21
25
  httparty.gemspec
26
+ lib/httparty.rb
22
27
  lib/httparty/cookie_hash.rb
23
28
  lib/httparty/core_extensions.rb
24
29
  lib/httparty/exceptions.rb
@@ -26,25 +31,17 @@ lib/httparty/module_inheritable_attributes.rb
26
31
  lib/httparty/request.rb
27
32
  lib/httparty/response.rb
28
33
  lib/httparty/version.rb
29
- lib/httparty.rb
30
- Manifest
31
- MIT-LICENSE
32
- Rakefile
33
- README
34
- setup.rb
35
34
  spec/fixtures/delicious.xml
36
35
  spec/fixtures/empty.xml
37
36
  spec/fixtures/google.html
38
37
  spec/fixtures/twitter.json
39
38
  spec/fixtures/twitter.xml
40
39
  spec/fixtures/undefined_method_add_node_for_nil.xml
41
- spec/hash_spec.rb
42
40
  spec/httparty/cookie_hash_spec.rb
43
41
  spec/httparty/request_spec.rb
44
42
  spec/httparty/response_spec.rb
45
43
  spec/httparty_spec.rb
46
44
  spec/spec.opts
47
45
  spec/spec_helper.rb
48
- spec/string_spec.rb
49
46
  website/css/common.css
50
47
  website/index.html
data/README.rdoc ADDED
@@ -0,0 +1,54 @@
1
+ = httparty
2
+
3
+ Makes http fun again!
4
+
5
+ == Note on Releases
6
+
7
+ 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.
8
+
9
+ * rake build_gemspec
10
+ * gem build httparty.gemspec
11
+ * gem install the gem that was built
12
+
13
+ == Note on Patches/Pull Requests
14
+
15
+ * Fork the project.
16
+ * Make your feature addition or bug fix.
17
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
18
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
19
+ * Send me a pull request. Bonus points for topic branches.
20
+
21
+ == Features:
22
+
23
+ * Easy get, post requests
24
+ * Basic http authentication
25
+ * Default request query string parameters (ie: for api keys that are needed on each request)
26
+ * Automatic parsing of JSON and XML into ruby hashes based on response content-type
27
+
28
+ == Examples
29
+
30
+ See http://github.com/jnunemaker/httparty/tree/master/examples
31
+
32
+ == Command Line Interface
33
+
34
+ httparty also includes the executable <tt>httparty</tt> which can be
35
+ used to query web services and examine the resulting output. By default
36
+ it will output the response as a pretty-printed Ruby object (useful for
37
+ grokking the structure of output). This can also be overridden to output
38
+ formatted XML or JSON. Execute <tt>httparty --help</tt> for all the
39
+ options. Below is an example of how easy it is.
40
+
41
+ httparty "http://twitter.com/statuses/public_timeline.json"
42
+
43
+ == Requirements
44
+
45
+ * Crack http://github.com/jnunemaker/crack/ - For XML and JSON parsing.
46
+ * You like to party!
47
+
48
+ == Install
49
+
50
+ * sudo gem install httparty
51
+
52
+ == Docs
53
+
54
+ http://rdoc.info/projects/jnunemaker/httparty
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ require 'spec/rake/spectask'
8
8
  require "lib/#{ProjectName}/version"
9
9
  require 'cucumber/rake/task'
10
10
 
11
- Echoe.new(ProjectName, HTTParty::Version) do |p|
11
+ Echoe.new("kerryb-#{ProjectName}", HTTParty::Version) do |p|
12
12
  p.description = "Makes http fun! Also, makes consuming restful web services dead easy."
13
13
  p.install_message = "When you HTTParty, you must party hard!"
14
14
  p.url = "http://#{ProjectName}.rubyforge.org"
data/httparty.gemspec CHANGED
@@ -2,39 +2,36 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{httparty}
5
- s.version = "0.4.3"
5
+ s.version = "0.4.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Nunemaker"]
9
- s.date = %q{2009-04-23}
9
+ s.date = %q{2009-08-03}
10
10
  s.default_executable = %q{httparty}
11
11
  s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
12
12
  s.email = %q{nunemaker@gmail.com}
13
13
  s.executables = ["httparty"]
14
- 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"]
15
- 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", "setup.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/hash_spec.rb", "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", "spec/string_spec.rb", "website/css/common.css", "website/index.html"]
14
+ 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"]
15
+ 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"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://httparty.rubyforge.org}
18
18
  s.post_install_message = %q{When you HTTParty, you must party hard!}
19
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Httparty", "--main", "README"]
19
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Httparty", "--main", "README.rdoc"]
20
20
  s.require_paths = ["lib"]
21
21
  s.rubyforge_project = %q{httparty}
22
- s.rubygems_version = %q{1.3.1}
22
+ s.rubygems_version = %q{1.3.2}
23
23
  s.summary = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
24
24
 
25
25
  if s.respond_to? :specification_version then
26
26
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
- s.specification_version = 2
27
+ s.specification_version = 3
28
28
 
29
29
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
30
  s.add_runtime_dependency(%q<crack>, [">= 0.1.1"])
31
- s.add_development_dependency(%q<echoe>, [">= 0"])
32
31
  else
33
32
  s.add_dependency(%q<crack>, [">= 0.1.1"])
34
- s.add_dependency(%q<echoe>, [">= 0"])
35
33
  end
36
34
  else
37
35
  s.add_dependency(%q<crack>, [">= 0.1.1"])
38
- s.add_dependency(%q<echoe>, [">= 0"])
39
36
  end
40
37
  end
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{kerryb-httparty}
5
+ s.version = "0.4.4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["John Nunemaker"]
9
+ s.date = %q{2010-04-08}
10
+ s.default_executable = %q{httparty}
11
+ s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
12
+ s.email = %q{nunemaker@gmail.com}
13
+ s.executables = ["httparty"]
14
+ s.extra_rdoc_files = ["README.rdoc", "bin/httparty", "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"]
15
+ s.files = ["History", "MIT-LICENSE", "Manifest", "README.rdoc", "Rakefile", "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", "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", "kerryb-httparty.gemspec"]
16
+ s.homepage = %q{http://httparty.rubyforge.org}
17
+ s.post_install_message = %q{When you HTTParty, you must party hard!}
18
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Kerryb-httparty", "--main", "README.rdoc"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{kerryb-httparty}
21
+ s.rubygems_version = %q{1.3.6}
22
+ s.summary = %q{Makes http fun! Also, makes consuming restful web services dead easy.}
23
+
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 3
27
+
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ s.add_runtime_dependency(%q<crack>, [">= 0.1.1"])
30
+ else
31
+ s.add_dependency(%q<crack>, [">= 0.1.1"])
32
+ end
33
+ else
34
+ s.add_dependency(%q<crack>, [">= 0.1.1"])
35
+ end
36
+ end
data/lib/httparty.rb CHANGED
@@ -7,6 +7,8 @@ require 'rubygems'
7
7
  gem 'crack'
8
8
  require 'crack'
9
9
 
10
+ require 'httparty/cookie_hash'
11
+
10
12
  module HTTParty
11
13
 
12
14
  AllowedFormats = {
@@ -26,7 +28,9 @@ module HTTParty
26
28
  base.extend ClassMethods
27
29
  base.send :include, HTTParty::ModuleInheritableAttributes
28
30
  base.send(:mattr_inheritable, :default_options)
31
+ base.send(:mattr_inheritable, :default_cookies)
29
32
  base.instance_variable_set("@default_options", {})
33
+ base.instance_variable_set("@default_cookies", CookieHash.new)
30
34
  end
31
35
 
32
36
  module ClassMethods
@@ -90,8 +94,7 @@ module HTTParty
90
94
 
91
95
  def cookies(h={})
92
96
  raise ArgumentError, 'Cookies must be a hash' unless h.is_a?(Hash)
93
- default_options[:cookies] ||= CookieHash.new
94
- default_options[:cookies].add_cookies(h)
97
+ default_cookies.add_cookies(h)
95
98
  end
96
99
 
97
100
  # Allows setting the format with which to parse.
@@ -102,7 +105,7 @@ module HTTParty
102
105
  # format :json
103
106
  # end
104
107
  def format(f)
105
- raise UnsupportedFormat, "Must be one of: #{AllowedFormats.values.uniq.join(', ')}" unless AllowedFormats.value?(f)
108
+ raise UnsupportedFormat, "Must be one of: #{AllowedFormats.values.map { |v| v.to_s }.uniq.sort.join(', ')}" unless AllowedFormats.value?(f)
106
109
  default_options[:format] = f
107
110
  end
108
111
 
@@ -157,11 +160,10 @@ module HTTParty
157
160
  end
158
161
 
159
162
  def process_cookies(options) #:nodoc:
160
- return unless options[:cookies] || default_options[:cookies]
163
+ return unless options[:cookies] || default_cookies
161
164
  options[:headers] ||= {}
162
- options[:headers]["cookie"] = cookies(options[:cookies] || {}).to_cookie_string
165
+ options[:headers]["cookie"] = cookies.merge(options[:cookies] || {}).to_cookie_string
163
166
 
164
- default_options.delete(:cookies)
165
167
  options.delete(:cookies)
166
168
  end
167
169
  end
@@ -198,7 +200,6 @@ module HTTParty
198
200
  end
199
201
  end
200
202
 
201
- require 'httparty/cookie_hash'
202
203
  require 'httparty/core_extensions'
203
204
  require 'httparty/exceptions'
204
205
  require 'httparty/request'
@@ -1,5 +1,9 @@
1
- class BlankSlate #:nodoc:
2
- instance_methods.each { |m| undef_method m unless m =~ /^__/ }
1
+ if RUBY_VERSION.to_f == 1.8
2
+ class BlankSlate #:nodoc:
3
+ instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval|object_id/ }
4
+ end
5
+ else
6
+ class BlankSlate < BasicObject; end
3
7
  end
4
8
 
5
9
  # 1.8.6 has mistyping of transitive in if statement
@@ -41,28 +41,42 @@ module HTTParty
41
41
  end
42
42
 
43
43
  private
44
+ # def http
45
+ # http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport])
46
+ # http.use_ssl = (uri.port == 443)
47
+ # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
48
+ # http
49
+ # end
50
+
44
51
  def http
45
52
  http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport])
46
53
  http.use_ssl = (uri.port == 443 || uri.scheme == 'https')
47
54
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
55
+ if options[:timeout] && options[:timeout].is_a?(Integer)
56
+ http.open_timeout = options[:timeout]
57
+ http.read_timeout = options[:timeout]
58
+ end
48
59
  http
49
60
  end
61
+
50
62
 
51
- def configure_basic_auth
52
- @raw_request.basic_auth(options[:basic_auth][:username], options[:basic_auth][:password])
63
+ def body
64
+ options[:body].is_a?(Hash) ? options[:body].to_params : options[:body]
65
+ end
66
+
67
+ def username
68
+ options[:basic_auth][:username]
69
+ end
70
+
71
+ def password
72
+ options[:basic_auth][:password]
53
73
  end
54
74
 
55
75
  def setup_raw_request
56
76
  @raw_request = http_method.new(uri.request_uri)
57
-
58
- if post? && options[:query]
59
- @raw_request.set_form_data(options[:query])
60
- end
61
-
62
- @raw_request.body = options[:body].is_a?(Hash) ? options[:body].to_params : options[:body] unless options[:body].blank?
63
- @raw_request.initialize_http_header options[:headers]
64
-
65
- configure_basic_auth if options[:basic_auth]
77
+ @raw_request.body = body if body
78
+ @raw_request.initialize_http_header(options[:headers])
79
+ @raw_request.basic_auth(username, password) if options[:basic_auth]
66
80
  end
67
81
 
68
82
  def perform_actual_request
@@ -77,13 +91,13 @@ module HTTParty
77
91
 
78
92
  def query_string(uri)
79
93
  query_string_parts = []
80
- query_string_parts << uri.query unless uri.query.blank?
94
+ query_string_parts << uri.query unless uri.query.nil?
81
95
 
82
96
  if options[:query].is_a?(Hash)
83
97
  query_string_parts << options[:default_params].merge(options[:query]).to_params
84
98
  else
85
- query_string_parts << options[:default_params].to_params unless options[:default_params].blank?
86
- query_string_parts << options[:query] unless options[:query].blank?
99
+ query_string_parts << options[:default_params].to_params unless options[:default_params].nil?
100
+ query_string_parts << options[:query] unless options[:query].nil?
87
101
  end
88
102
 
89
103
  query_string_parts.size > 0 ? query_string_parts.join('&') : nil
@@ -1,3 +1,3 @@
1
1
  module HTTParty #:nodoc:
2
- Version = '0.4.3'
2
+ Version = '0.4.4'
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '../spec_helper')
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
2
2
 
3
3
  describe HTTParty::CookieHash do
4
4
  before(:each) do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '..', 'spec_helper')
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
2
 
3
3
  describe HTTParty::Request do
4
4
  def stub_response(body, code = 200)
@@ -35,6 +35,11 @@ describe HTTParty::Request do
35
35
  request = HTTParty::Request.new(Net::HTTP::Get, 'http://foobar.com')
36
36
  request.send(:http).use_ssl?.should == false
37
37
  end
38
+
39
+ it "should use ssl for https scheme" do
40
+ request = HTTParty::Request.new(Net::HTTP::Get, 'https://foobar.com')
41
+ request.send(:http).use_ssl?.should == true
42
+ end
38
43
 
39
44
  it 'should use ssl for https scheme' do
40
45
  request = HTTParty::Request.new(Net::HTTP::Get, 'https://foobar.com')
@@ -46,6 +51,23 @@ describe HTTParty::Request do
46
51
  @request.send(:setup_raw_request)
47
52
  @request.instance_variable_get(:@raw_request)['authorization'].should_not be_nil
48
53
  end
54
+
55
+ it "should change timeout when configured (if an Integer)" do
56
+ @request.send(:http).open_timeout.should be_nil
57
+ @request.send(:http).read_timeout.should == 60
58
+
59
+ invalid_timeout = "invalid"
60
+ invalid_timeout.is_a?(Integer).should be_false
61
+ @request.options[:timeout] = invalid_timeout
62
+ @request.send(:http).open_timeout.should be_nil
63
+ @request.send(:http).read_timeout.should == 60
64
+
65
+ timeout = 30
66
+ timeout.is_a?(Integer).should be_true
67
+ @request.options[:timeout] = timeout
68
+ @request.send(:http).open_timeout.should == timeout
69
+ @request.send(:http).read_timeout.should == timeout
70
+ end
49
71
  end
50
72
 
51
73
  describe '#format_from_mimetype' do
@@ -114,7 +136,6 @@ describe HTTParty::Request do
114
136
  end
115
137
 
116
138
  describe 'with non-200 responses' do
117
-
118
139
  it 'should return a valid object for 4xx response' do
119
140
  stub_response '<foo><bar>yes</bar></foo>', 401
120
141
  resp = @request.perform
@@ -130,7 +151,6 @@ describe HTTParty::Request do
130
151
  resp.body.should == "<foo><bar>error</bar></foo>"
131
152
  resp['foo']['bar'].should == "error"
132
153
  end
133
-
134
154
  end
135
155
  end
136
156
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '..', 'spec_helper')
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
2
 
3
3
  describe HTTParty::Response do
4
4
  describe "initialization" do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
 
3
3
  describe HTTParty do
4
4
  before(:each) do
@@ -96,6 +96,13 @@ describe HTTParty do
96
96
  @klass.get("")
97
97
  end
98
98
 
99
+ it "should pass the proper cookies when requested multiple times" do
100
+ 2.times do
101
+ expect_cookie_header "type=snickerdoodle"
102
+ @klass.get("")
103
+ end
104
+ end
105
+
99
106
  it "should allow the class defaults to be overridden" do
100
107
  expect_cookie_header "type=chocolate_chip"
101
108
 
@@ -175,7 +182,7 @@ describe HTTParty do
175
182
  it 'should only print each format once with an exception' do
176
183
  lambda do
177
184
  @klass.format :foobar
178
- end.should raise_error(HTTParty::UnsupportedFormat, "Must be one of: json, plain, html, yaml, xml")
185
+ end.should raise_error(HTTParty::UnsupportedFormat, "Must be one of: html, json, plain, xml, yaml")
179
186
  end
180
187
 
181
188
  end