No commit activity in last 3 years
No release in over 3 years
RackTest driver for Capybara, but with remote request support thanks to mechanize
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.0.1, ~> 2.0
~> 2.5
 Project Readme

Capybara-mechanize

Build Status

This gems makes it possible to use Capybara for (partially) remote testing. It inherits most functionality from the RackTest driver and only uses Mechanize for remote requests.

It is currently in use to test the integration between a Rails application and Twitter authorization and sharing.

This gem is a Capybara extension. I have been inspired by the Capybara driver and some earlier efforts for a Mechanize driver.

Thanks to Pinkelstar for giving me the time and the need to develop this gem.

Installation

gem install capybara-mechanize

Usage without Cucumber

require 'capybara/mechanize'

Further configuration of Mechanize

Upon instantiation of a Driver, you can configure mechanize agent options in a #configure block:

Capybara.register_driver :mechanize do |app|
  driver = Capybara::Mechanize::Driver.new(app)
  driver.configure do |agent|
    # Configure other Mechanize options here.
    agent.log = Logger.new "mech.log"
    agent.user_agent_alias = 'Mac Safari'
  end
  driver
end

Usage with Cucumber and tags

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

require 'capybara/mechanize/cucumber'

The following scenario will then be using the Mechanize driver

@mechanize
Scenario: do something remote
  When I click the remote link

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

Run bundler

bundle install

Then you are ready to run the test like so

bundle exec rake spec

Todo

  • Test this driver with non-rack/non-ruby projects

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-2013 Jeroen van Dijk. See LICENSE for details.