Skip to content

Commit

Permalink
Added missing http_mock file for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
nbibler committed May 23, 2008
1 parent b37187e commit d972133
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
25 changes: 25 additions & 0 deletions test/http_mock.rb
@@ -0,0 +1,25 @@
require 'net/http'
require 'net/https'

# patch Net::HTTP so un caged requests don't go over the wire
module Net #:nodoc:
class HTTP #:nodoc:
alias :old_net_http_request :request
alias :old_net_http_connect :connect

def request(req, body = nil, &block)
prot = use_ssl ? "https" : "http"
uri_cls = use_ssl ? URI::HTTPS : URI::HTTP
query = req.path.split('?',2)
opts = {:host => self.address,
:port => self.port, :path => query[0]}
opts[:query] = query[1] if query[1]
uri = uri_cls.build(opts)
raise ArgumentError.new("#{req.method} method to #{uri} not being handled in testing")
end

def connect
raise ArgumentError.new("connect not being handled in testing")
end
end
end
10 changes: 5 additions & 5 deletions test/test_helper.rb
Expand Up @@ -7,11 +7,11 @@
require 'mocha'
require 'shoulda'

# begin
# require 'redgreen'
# rescue LoadError
# nil
# end
begin
require 'redgreen'
rescue LoadError
nil
end

require 'devpay'

Expand Down

0 comments on commit d972133

Please sign in to comment.