Sha256: 5b64d65bd1e93f2c1a5fb1083d833e1544ab2d4df1e668dbda14d056c92fd457
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
module RestfullyAccessibleStub def stub_get_request(url, resource_name) stub_request(:get, url) .with( headers: request_headers ).to_return( status: 200, body: %Q[{#{resource_name}: "dummy"}] ) end def stub_get_request_with_json_response(url, body) stub_request(:get, url) .with( headers: request_headers ).to_return( status: 200, headers: {'Content-Type' => 'application/json'}, body: body.class == String ? body : body.to_json ) end def stub_get_request_not_found(url) stub_request(:get, url) .with( headers: request_headers ).to_return( status: 404, body: "itemNotFound" ) end def stub_get_request_unauthorized(url) stub_request(:get, url) .with( headers: request_headers ).to_return( status: 401, body: "unauthorized" ) end def stub_post_request(url, body, response = {}) stub_request(:post,url) .with( headers: request_headers ).to_return( status: 202, headers: {'Content-Type' => 'application/json'}, body: response.to_json ) end def stub_put_request(url, body, response = {}) stub_request(:put,url) .with( headers: request_headers.merge({'Content-Type' => 'application/json'}), body: body.to_json, ).to_return( status: 200, headers: {'Content-Type' => 'application/json'}, body: response.to_json ) end def stub_delete_request(url, response = {}) stub_request(:delete,url) .with( headers: request_headers ).to_return( status: 200, headers: {'Content-Type' => 'application/json'}, body: response.to_json ) end def request_headers {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>"Yao/#{Yao::VERSION} Faraday/#{Faraday::VERSION}"} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yao-0.21.0 | test/support/restfully_accesible_stub.rb |
yao-0.20.0 | test/support/restfully_accesible_stub.rb |