Created
April 16, 2021 11:12
-
-
Save langalex/f2a4cdb3f6a768560f0188efdd1951bc to your computer and use it in GitHub Desktop.
rest-client stub bad request error with RSpec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RestClientHelpers | |
def bad_request_error(json_body) | |
request = double(:request, redirection_history: nil) | |
net_http_res = double(:response, to_hash: {}, code: 400) | |
response = RestClient::Response.create(json_body.to_json, net_http_res, request) | |
RestClient::BadRequest.new response, 400 | |
end | |
end | |
RSpec.configure do |c| | |
c.include RestClientHelpers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing this 👍