module Soaspec::RestMethods

Contains commonly used REST methods. Include this module in the spec where you want to use it

TODO: For some reason from 'soaspec pry' sinatra always gets loaded instead of this

@example

include Soaspec::RestMethods

context CustomExchangeHandler.new('Create Notes') do
  post(:minimum_data, body: { subject: 'Minimal' }) do
    it_behaves_like 'success scenario'
    its(:subject) { is_expected.to eq 'Minimal' }
  end

  post(:one_note, body: { subject: 'One', note: { 'Note 1' } }) do
    it_behaves_like 'success scenario'
    it 'has 1 note' do
      expect(get(subject.id).values_at_path('notes').count).to eq 1
    end
  end
end

Public Instance Methods

delete(name, params = {}) click to toggle source

Make REST Delete Exchange @param [String] name Name of test displayed @param [Hash] params Exchange parameters @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body

# File lib/soaspec/exchange_handlers/rest_methods.rb, line 61
def delete(name, params = {})
  Exchange.new(name, method: :delete, **params)
end
get(name, params = {}) click to toggle source

Make REST Get Exchange @param [String] name Name of test displayed @param [Hash] params Exchange parameters @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body

# File lib/soaspec/exchange_handlers/rest_methods.rb, line 53
def get(name, params = {})
  Exchange.new(name, method: :get, **params)
end
patch(name, params = {}) click to toggle source

Make REST Patch Exchange @param [String] name Name of test displayed @param [Hash] params Exchange parameters @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body

# File lib/soaspec/exchange_handlers/rest_methods.rb, line 37
def patch(name, params = {})
  Exchange.new(name, method: :patch, **params)
end
post(name, params = {}) click to toggle source

Make REST Post Exchange @param [String] name Name of test displayed @param [Hash] params Exchange parameters @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body

# File lib/soaspec/exchange_handlers/rest_methods.rb, line 29
def post(name, params = {})
  Exchange.new(name, method: :post, **params)
end
put(name, params = {}) click to toggle source

Make REST Put Exchange @param [String] name Name of test displayed @param [Hash] params Exchange parameters @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body

# File lib/soaspec/exchange_handlers/rest_methods.rb, line 45
def put(name, params = {})
  Exchange.new(name, method: :put, **params)
end