No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
examples
lib/capybara
spec
.gitignore
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
capybara-async_runner.gemspec

README.md

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