2008-12-06 19:41:23 -05:00
|
|
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'httparty')
|
2009-09-12 22:52:43 -04:00
|
|
|
gem 'rspec', '1.2.8'
|
2009-08-22 21:14:32 -04:00
|
|
|
gem 'fakeweb'
|
2009-09-08 21:41:13 -04:00
|
|
|
require 'spec/autorun'
|
2009-08-22 21:14:32 -04:00
|
|
|
require 'fakeweb'
|
|
|
|
|
|
|
|
FakeWeb.allow_net_connect = false
|
|
|
|
|
2008-12-06 19:41:23 -05:00
|
|
|
def file_fixture(filename)
|
|
|
|
open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read
|
|
|
|
end
|
|
|
|
|
2008-12-06 22:47:01 -05:00
|
|
|
def stub_http_response_with(filename)
|
|
|
|
format = filename.split('.').last.intern
|
|
|
|
data = file_fixture(filename)
|
2008-12-22 14:30:31 -05:00
|
|
|
|
2008-12-06 19:41:23 -05:00
|
|
|
response = Net::HTTPOK.new("1.1", 200, "Content for you")
|
|
|
|
response.stub!(:body).and_return(data)
|
2008-12-22 14:30:31 -05:00
|
|
|
|
|
|
|
http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
|
|
|
|
http_request.stub!(:perform_actual_request).and_return(response)
|
|
|
|
|
2008-12-06 19:41:23 -05:00
|
|
|
HTTParty::Request.should_receive(:new).and_return(http_request)
|
|
|
|
end
|