require 'spec_helper' describe 'Test Relays' do before(:each) do WebMock.reset! end before do @baruwapi = BaruwaAPI.new('https://testbaruwa.com', '6e2347bc-278e-42f6-a84b-fa1766140cbd') end it 'should get a relay' do relayid = 2 stub_request(:get, "https://testbaruwa.com/api/v1/relays/#{relayid}"). with(:body => false, :headers => {'Accept'=>'*/*', 'User-Agent'=>'BaruwaAPI-Ruby', 'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}). to_return(:status => 200, :body => "", :headers => {}) @baruwapi.get_relay(relayid) expect(WebMock).to have_requested(:get, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{relayid}") end it 'should create a relay' do orgid = 2 stub_request(:post, "https://testbaruwa.com/api/v1/relays/#{orgid}"). with(:body => {}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'BaruwaAPI-Ruby', 'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}). to_return(:status => 200, :body => "", :headers => {}) @baruwapi.create_relay(orgid, {}) expect(WebMock).to have_requested(:post, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{orgid}") end it 'should update a relay' do relayid = 2 stub_request(:put, "https://testbaruwa.com/api/v1/relays/#{relayid}"). with(:body => {}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'BaruwaAPI-Ruby', 'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}). to_return(:status => 200, :body => "", :headers => {}) @baruwapi.update_relay(relayid, {}) expect(WebMock).to have_requested(:put, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{relayid}") end it 'should delete a relay' do relayid = 2 stub_request(:delete, "https://testbaruwa.com/api/v1/relays/#{relayid}"). with(:body => {}, :headers => {'Accept'=>'*/*', 'User-Agent'=>'BaruwaAPI-Ruby', 'Authorization'=>'Bearer 6e2347bc-278e-42f6-a84b-fa1766140cbd'}). to_return(:status => 200, :body => "", :headers => {}) @baruwapi.delete_relay(relayid, {}) expect(WebMock).to have_requested(:delete, "#{@baruwapi.instance_variable_get(:@baruwa_url)}/relays/#{relayid}") end end