No commit activity in last 3 years
No release in over 3 years
Faraday driver for Capybara, allowing testing of REST APIs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

~> 1.1.2
= 0.8.7
~> 1.0
 Project Readme

Capybara-restfulie

This gems makes it possible to use Faraday for remote testing.

This gem is a Capybara extension. The structure of the gem is taken from the work done on Capybara-mechanize.

Installation

gem install capybara-faraday

Usage without Cucumber

require 'capybara/faraday'

Usage with Cucumber and tags

A @faraday tag is added to your hooks when you add the following line to your env.rb

require 'capybara/faraday/cucumber'

The following scenario will then be using the Faraday driver

@faraday
Scenario: do something with the API
  Given I send and accept JSON
  When I send a GET request to /users

If you want to use a specific faraday supported adapter, you need to install the dependency and then specify the tag matching it:

To use Typhoeus

@faraday_typhoeus
Scenario: do something with the API
  Given I send and accept JSON
  When I send a GET request to /users

To use Patron

@faraday_patron
Scenario: do something with the API
  Given I send and accept JSON
  When I send a GET request to /users    

Remote testing

When you want to use this driver to test a remote application. You have to set the app_host:

Capybara.app_host = "http://www.yourapp.com"

Note that I haven't tested this case for my self yet. The Capybara tests pass for this situation though so it should work! Please provide me with feedback if it doesn't.

Running tests

For the tests to make sense, you need to simulate a remote server, simply add this line to your hosts file:

127.0.0.1 capybara-testapp.heroku.com

Run bundler

bundle install

Then you are ready to run the test like so

rake spec

Caveats

The focus being to provide a working driver to test APIs, not all Capybara goodness are implemented. Everything related to submitting forms, clicking buttons, clicking checkboxes or javascript will not work with this driver.

Todo

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2010 Tron Jonathan and HALTER Joseph. See LICENSE for details.