Skip to content

Commit

Permalink
Merge remote branch 'chrisZingel/master'
Browse files Browse the repository at this point in the history
* chrisZingel/master:
  Add a fix for the VCR gem that produces an error for  head requests
  • Loading branch information
chrisk committed Aug 15, 2010
2 parents cfb45fe + 58dc687 commit 231a94c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fake_web/responder.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def headers_extracted_from_options
} }
end end


def body def body
return '' unless options.has_key?(:body) return '' unless options.has_key?(:body)&&!options[:body].nil?


options[:body] = options[:body].to_s if defined?(Pathname) && options[:body].is_a?(Pathname) options[:body] = options[:body].to_s if defined?(Pathname) && options[:body].is_a?(Pathname)


Expand Down
5 changes: 5 additions & 0 deletions test/test_response_headers.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,11 @@
require 'test_helper' require 'test_helper'


class TestResponseHeaders < Test::Unit::TestCase class TestResponseHeaders < Test::Unit::TestCase
def test_head_request_provides_redirect_location
FakeWeb.register_uri(:head, "http://example.com/", {:status=>["301", "Moved Permanently"], "x-tiny"=>["cache 0.00051307678222656"], "location"=>["http://www.newexample.com"], "x-powered-by"=>["PHP/5.3.2"], "connection"=>["close"], "content-type"=>["text/html"], "server"=>["TinyURL/1.6"], "date"=>["Fri, 06 Aug 2010 08:38:03 GMT"], :body=>nil})
response = Net::HTTP.start("example.com") { |query| query.head("/") }
assert_equal response['location'],"http://www.newexample.com"
end


def test_content_type_when_registering_with_string_and_content_type_header_as_symbol_option def test_content_type_when_registering_with_string_and_content_type_header_as_symbol_option
FakeWeb.register_uri(:get, "http://example.com/users.json", :body => '[{"username": "chrisk"}]', :content_type => "application/json") FakeWeb.register_uri(:get, "http://example.com/users.json", :body => '[{"username": "chrisk"}]', :content_type => "application/json")
Expand Down

0 comments on commit 231a94c

Please sign in to comment.