Repository is archived
No commit activity in last 3 years
No release in over 3 years
Gem for running ascynrhonous jobs in Capybara.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
>= 0
~> 10.0
~> 3.2.0
~> 1.2.0
 Project Readme

Capybara::AsyncRunner

Build Status Code Climate Inline docs

This is a ruby gem for running asynchronous JavaScript code synchronously with Capybara.

Installation

Add this line to your application's Gemfile:

gem 'capybara-async_runner'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capybara-async_runner

Usage

Read this blog post first. Then check out examples dir.

How to use

  • Setup a directory with command templates
Capybara::AsyncRunner.setup do |config|
  config.commands_directory = Rails.root.join('directory/with/templates')
end
  • Create a command
class MyCommand < Capybara::AsyncRunner::Command
  # specify the name
  self.command_name = :my_command
  # specify a path to template
  self.template = 'template_name'
  # specify a response
  response :done
end
  • Create a template file
// directory/with/templates/template_name.js.erb
yourCode(function(data) {
  <%= done(js[:data]) %>
})
  • Call the command
Capybara::AsyncRunner.run(:my_command)
# => data from your script

Contributing

  1. Fork it ( https://github.com/[my-github-username]/capybara-async_runner/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