spec/support/webmock_helper.rb in letsfreckle-client-0.1.2 vs spec/support/webmock_helper.rb in letsfreckle-client-0.2.0

- old
+ new

@@ -1,5 +1,17 @@ module WebMockHelper def load_response(resource) File.read(File.join(File.dirname(__FILE__), '/../responses', "#{resource}.xml.response")) end -end \ No newline at end of file + + def url_for_resource(resource) + "#{LetsFreckle::Entry.base_api_url}#{LetsFreckle::Entry.relative_path_for(resource)}" + end + + def stub_api_request(resource) + stub_http_request(:get, url_for_resource(resource)). + with(:headers => { 'Accept' =>'*/*', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' =>'Ruby' }). + to_return(:body => load_response(resource)) + end +end