Sha256: 40d725febe6d492695938f6769f0836bb7ec487d13752b6116534916e440b437

Contents?: true

Size: 743 Bytes

Versions: 2

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

module ControllerTestHelpers
  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_request(method_name, endpoint, params = nil, headers = nil)
    if Rails.version.starts_with?('4')
      send(method_name, endpoint, params, headers)
    else
      options = { params: params }
      options[:headers] = headers if headers
      send(method_name, endpoint, **options)
    end
  end
end

RSpec.configure do |config|
  config.include ControllerTestHelpers, type: :controller
  config.include ControllerTestHelpers, type: :request
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
g5_authenticatable_api-1.0.0 spec/support/controller_test_helpers.rb
g5_authenticatable_api-1.0.0.pre.1 spec/support/controller_test_helpers.rb