spec/spec_helper.rb in restful_resource-1.6.0 vs spec/spec_helper.rb in restful_resource-2.0.1
- old
+ new
@@ -1,46 +1,47 @@
require 'rspec'
+require 'rspec/its'
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)
+def expect_get(url, response, headers: {})
+ expect(@mock_http).to receive(:get).with(url, headers: headers).and_return(response)
end
-def expect_delete(url, response)
- expect(@mock_http).to receive(:delete).with(url).and_return(response)
+def expect_delete(url, response, headers: {})
+ expect(@mock_http).to receive(:delete).with(url, headers: headers).and_return(response)
end
-def expect_put(url, response, data: {})
- expect(@mock_http).to receive(:put).with(url, data: data).and_return(response)
+def expect_put(url, response, data: {}, headers: {})
+ expect(@mock_http).to receive(:put).with(url, data: data, headers: headers).and_return(response)
end
-def expect_post(url, response, data: {})
- expect(@mock_http).to receive(:post).with(url, data: data).and_return(response)
+def expect_post(url, response, data: {}, headers: {})
+ expect(@mock_http).to receive(:post).with(url, data: data, headers: headers).and_return(response)
end
def expect_get_with_unprocessable_entity(url, response)
request = RestfulResource::Request.new(:get, url)
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(:get).with(url).and_raise(exception)
+ expect(@mock_http).to receive(:get).with(url, headers: {}).and_raise(exception)
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)
+ expect(@mock_http).to receive(:put).with(url, data: data, headers: {}).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)
+ expect(@mock_http).to receive(:post).with(url, data: data, headers: {}).and_raise(exception)
end