unobtainium driver providing API access via faraday
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
unobtainium-faraday.gemspec

README.md

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