Sha256: 5a57024c69d9dd63584f587862cdae51c5bda3b62e2b940994143c46250d3678
Contents?: true
Size: 1 KB
Versions: 18
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true # Methods for submitting test requests that are safe to use # under both rails 4.x and 5.x module SafeRequestHelpers def safe_get(endpoint, params = nil, headers = nil) safe_request(:get, endpoint, params, headers) end def safe_post(endpoint, params = nil, headers = nil) safe_request(:post, endpoint, params, headers) end def safe_put(endpoint, params = nil, headers = nil) safe_request(:put, endpoint, params, headers) end def safe_delete(endpoint, params = nil, headers = nil) safe_request(:delete, endpoint, params, headers) end def safe_request(method, endpoint, params, headers) if Rails.version.starts_with?('4') send(method, endpoint, params, headers) else options = { params: params } options[:headers] = headers if headers send(method, endpoint, **options) end end end RSpec.configure do |config| config.include SafeRequestHelpers, type: :controller config.include SafeRequestHelpers, type: :request end
Version data entries
18 entries across 18 versions & 1 rubygems