Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

unobtainium driver providing API access via faraday

License

Notifications You must be signed in to change notification settings

jfinkhaeuser/unobtainium-faraday

Repository files navigation

unobtainium-faraday

This gem provides a driver implementation for unobtainium based on faraday.

Gem Version Build status

To use it, require it after requiring unobtainium, then create the appropriate driver:

require 'unobtainium'
require 'unobtainium-faraday'

include Unobtainium::World

drv = driver(:faraday)

The main purpose of this gem is to make API testing a little easier. To that end, the driver (which is a faraday connection object) is initialized with some middleware, in particular faraday_json to fix some encoding issues in the default middleware.

If you're coming from faraday, initializing the driver/connection is going to feel a little different. Instead of the block-initialization favoured by faraday, you pass an options hash:

drv = driver(:faraday,
             uri: 'http://finkhaeuser.de',
             connection: {
               request: :json,
               response: [:logger, [:json, content_type: /\bjson$/ ]]
             })

Afterwards, using the driver is identical to faraday usage:

res = drv.get '/'
puts res.body

About

unobtainium driver providing API access via faraday

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages