No commit activity in last 3 years
No release in over 3 years
Testing APIs with Capybara isn't a great idea, but this makes it easier if you want to anyway.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

CapybaraApiHelpers

Simple helpers for testing an API with Capybara and rspec.

You're not supposed to test APIs with Capybara, but sometimes it's convenient.

Installation

Add this line to your application's Gemfile:

gem 'capybara_api_helpers'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capybara_api_helpers

In your spec_helper.rb, add this line:

config.include CapybaraApiHelpers, type: :feature

Usage

In your specs, you can now test your api with the methods hit_api (which defaults to GET), put_api, and post_api. They will do what (I hope) is expected, and will use the JSON format.

Here's an example:

response = hit_api 'v2/things'

expect(response.size).to eq 5

first_thing = things.first

expect(first_thing['name']).to eq 'Chapstick'

Contributing

  1. Fork it ( https://github.com/[my-github-username]/capybara_api_helpers/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About Foraker Labs

Foraker Logo

Foraker Labs builds exciting web and mobile apps in Boulder, CO. Our work powers a wide variety of businesses with many different needs. We love open source software, and we're proud to contribute where we can. Interested to learn more? Contact us today.

This project is maintained by Foraker Labs. The names and logos of Foraker Labs are fully owned and copyright Foraker Design, LLC.