Sha256: d6a00ef303b0e558ccb4b30cf2d18dd29425cfbb17e622888806414cef0ef774

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

require 'rspec'
require_relative '../lib/restful_resource'
require_relative 'fixtures'

RSpec.configure do |config|
  config.color = true
  config.formatter = :progress
end


def expect_get(url, response)
  expect(@mock_http).to receive(:get).with(url).and_return(response)
end

def expect_delete(url, response)
  expect(@mock_http).to receive(:delete).with(url).and_return(response)
end

def expect_put(url, response, data: {})
  expect(@mock_http).to receive(:put).with(url, data: data).and_return(response)
end

def expect_post(url, response, data: {})
  expect(@mock_http).to receive(:post).with(url, data: data).and_return(response)
end

def expect_put_with_unprocessable_entity(url, response, data: {})
  request = RestfulResource::Request.new(:put, url, body: data)
  rest_client_response = OpenStruct.new({body: response.body, headers: response.headers, code: response.status})
  exception = RestfulResource::HttpClient::UnprocessableEntity.new(request, rest_client_response)
  expect(@mock_http).to receive(:put).with(url, data: data).and_raise(exception)
end

def expect_post_with_unprocessable_entity(url, response, data: {})
  request = RestfulResource::Request.new(:put, url, body: data)
  rest_client_response = OpenStruct.new({body: response.body, headers: response.headers, code: response.status})
  exception = RestfulResource::HttpClient::UnprocessableEntity.new(request, rest_client_response)
  expect(@mock_http).to receive(:post).with(url, data: data).and_raise(exception)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
restful_resource-1.3.0 spec/spec_helper.rb
restful_resource-1.2.2 spec/spec_helper.rb
restful_resource-1.2.1 spec/spec_helper.rb
restful_resource-1.2.0 spec/spec_helper.rb
restful_resource-1.1.0 spec/spec_helper.rb
restful_resource-1.0.0 spec/spec_helper.rb