GithubHelp home page GithubHelp logo

hasimo / capybara-mechanize Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phillbaker/capybara-mechanize

1.0 2.0 0.0 546 KB

RackTest driver for Capybara with remote request support

License: MIT License

Ruby 100.00%

capybara-mechanize's Introduction

Capybara-mechanize

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'

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

Until this library is merged with capybara there needs to be local app and you need to add the following to your host file:

127.0.0.1 capybara-testapp.heroku.com 

Run bundler

bundle install

Run the app with the following line:

bundle exec ruby -rrubygems lib/capybara/spec/extended_test_app.rb

Then you are ready to run the test like so

rake spec

Todo

  • Make the last 12 failing remote session spec pass, see remote_mechanize_spec and uncomment one line there to see them fail
  • 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 Jeroen van Dijk. See LICENSE for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.