2008-12-06 22:01:42 -05:00
|
|
|
require 'rubygems'
|
|
|
|
gem 'rspec'
|
|
|
|
require 'spec'
|
2008-12-06 19:41:23 -05:00
|
|
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'httparty')
|
|
|
|
|
|
|
|
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
|