Project

General

Profile

« Previous | Next » 

Revision 6e7af6fc

Added by Dominic Cleal almost 8 years ago

fixes #15573 - support rest-client 2.x

Add a test helper that understands how to create fake responses for both
supported 1.8 and 2.x versions.

View differences:

test/lib/proxy_api/template_test.rb
@template = ProxyAPI::Template.new({:url => @url})
end
def fake_response(data)
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
net_http_resp.add_field 'Set-Cookie', 'Monster'
RestClient::Response.create(JSON(data), net_http_resp, nil, RestClient::Request.new(:method=>'get', :url=>'http://localhost:8443'))
end
test "constructor sets url base path with /unattended" do
expected = "#{@url}/unattended"
assert_equal(expected, @template.url)
end
test "should get template server url" do
@template.expects(:get).with('templateServer').returns(fake_response({'templateServer'=>'mytemplateserver'}))
@template.expects(:get).with('templateServer').returns(fake_rest_client_response({'templateServer'=>'mytemplateserver'}))
assert_equal('mytemplateserver', @template.template_url)
end
end

Also available in: Unified diff