Sha256: 0819957ccf403b4c450a826cb8f25ffcc5e4d3af2d7941b331a562e80a39b044
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
require 'rest_in_peace/api_call' require 'ostruct' describe RESTinPeace::ApiCall do let(:api) { double } let(:url_template) { '/rip/:id' } let(:klass) { OpenStruct } let(:params) { {id: 1} } let(:api_call) { RESTinPeace::ApiCall.new(api, url_template, klass, params) } let(:response) { OpenStruct.new(body: []) } describe '#get' do context 'with enough parameters for the template' do it 'calls the api with the parameters' do expect(api).to receive(:get).with('/rip/1', {}).and_return(response) api_call.get end end context 'with more parameters than needed' do let(:params) { { id: 1, name: 'test' } } it 'uses also the additional parameters' do expect(api).to receive(:get).with('/rip/1', { name: 'test' }).and_return(response) api_call.get end end end describe '#post' do let(:url_template) { '/rip' } let(:params) { { name: 'test' } } it 'calls the api with the parameters' do expect(api).to receive(:post).with('/rip', { name: 'test' }).and_return(response) api_call.post end end describe '#patch' do let(:params) { { id: 1, name: 'test' } } it 'calls the api with the parameters' do expect(api).to receive(:patch).with('/rip/1', { name: 'test' }).and_return(response) api_call.patch end end describe '#delete' do it 'calls the api with the parameters' do expect(api).to receive(:delete).with('/rip/1', {}).and_return(response) api_call.delete end end end
Version data entries
5 entries across 5 versions & 1 rubygems