Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Harmony plugin for Ruby on Rails tests

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 public
Octocat-spinner-32 rails
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Manifest
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 docs.watchr
Octocat-spinner-32 holygrail.gemspec
Octocat-spinner-32 specs.watchr
README.md

HolyGrail

Summary

The Holy Grail of testing for front-end development; execute browser-less, console-based, javascript + DOM code right from within your Rails test suite.

HolyGrail is a Harmony plugin for Ruby on Rails.

Examples

Use the js method in your functional tests to execute javascript within the context of a view (the last response body). js returns the value of the last javascript statement, cast to an equivalent ruby object.

class PeopleControllerTest < ActionController::TestCase

  test "executes simple js" do
    assert_equal 2, js('1+1')
  end

  test "accesses the DOM" do
    get :foo
    assert_equal 'Foo', js("document.title")
    assert_equal  2,    js("document.getElementsByTagName('div').length")
  end
end

Install

Install the gem

# Note: there's a gem dependency bug in rubygems currently, so we'll have
# to install some dependencies manually. This will be fixed soon.
gem install stackdeck
gem install johnson -v "2.0.0.pre0" #exact version matters

gem install holygrail

and add it to your environment

config.gem "holygrail"

Acknowledgement

HolyGrail is based on Harmony, which in turn is a thin DSL wrapper around three amazing libs, Johnson, env.js and Envjs . The authors of those libs have been doing a huge amount of great work for quite a while, so please go recommend them on WorkingWithRails right now and/or follow them on github:

jbarnette, tenderlove, smparkes, wycats, matthewd, thatcher, jeresig

Special thanks go to smparkes for his patient help, and for providing the last puzzle pieces that made everything work together.

TODO

  • Support integration tests
  • Support Rails3

Links

Something went wrong with that request. Please try again.