Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stubbed request data and got tests to pass

git-svn-id: http://rubygems.rubyforge.org/svn/trunk@1800 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information...
commit b95028224bd7dc7b6f01428547fbe5cf72774aac 1 parent ecd6a4f
zenspider authored
Showing with 19 additions and 5 deletions.
  1. +19 −5 test/test_gem_remote_fetcher.rb
View
24 test/test_gem_remote_fetcher.rb
@@ -10,6 +10,11 @@
require 'webrick'
require 'zlib'
require 'rubygems/remote_fetcher'
+require 'ostruct'
+
+def o hash
+ OpenStruct.new(hash)
+end
# = Testing Proxy Settings
#
@@ -509,22 +514,21 @@ def conn.request(req)
def test_request
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
+ util_stub_connection_for o(:request => o(:body => :junk, :code => 200))
+
response = @fetcher.request uri
assert_equal 200, response.code
assert_equal :junk, response.body
-
- flunk "we suck"
end
def test_request_head
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
+ util_stub_connection_for o(:request => o(:body => '', :code => 200))
response = @fetcher.request uri, Net::HTTP::Head
assert_equal 200, response.code
assert_equal '', response.body
-
- flunk "we suck"
end
def test_zip
@@ -553,7 +557,17 @@ def test_yaml_error_on_size
end
end
- private
+ def util_stub_connection_for *data
+ def @fetcher.stub_data= ary
+ @stub_data = ary
+ end
+
+ def @fetcher.connection_for blah
+ return @stub_data.shift
+ end
+
+ @fetcher.stub_data = data
+ end
def assert_error(exception_class=Exception)
got_exception = false
Please sign in to comment.
Something went wrong with that request. Please try again.