• Stars
    star
    169
  • Rank 224,453 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 15 years ago
  • Updated over 14 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Harmony plugin for Ruby on Rails tests

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 and integration 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

Ajax requests in integration tests will be handled as expected

Install

Install the gem

# 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.pre3" #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

More Repositories

1

watchr

Modern continuous testing (flexible alternative to Autotest)
Ruby
1,277
star
2

harmony

Javascript + DOM in your ruby, the simple way
Ruby
446
star
3

every

Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables.
Ruby
75
star
4

nanotest

When all you need is #assert
Ruby
69
star
5

redgreen

Standalone redgreen eye candy for test results, ala autotest
Ruby
43
star
6

simple_router

Simple rack router
Ruby
28
star
7

unindent

Ruby method to unindent strings.
Ruby
27
star
8

phocus

Focus your tests
Ruby
25
star
9

rack-respond_to

Rack middleware port of Rails's respond_to feature
Ruby
23
star
10

attachment_fu_fixtures

Allows attachment_fu models to fully use fixtures. Ideal for seed, sample or dev data.
Ruby
17
star
11

montrealrb

Montreal.rb website source
Ruby
16
star
12

rack-accept-media-types

Rack convenience middleware for simplified handling of Accept header (Accept header parser).
Ruby
13
star
13

pathname

OO wrapper for node's path/fs modules. Based on Ruby's sweet Pathname class
JavaScript
12
star
14

rack-abstract-format

Rack middleware that abstracts format (extension) away from the path (into env)
Ruby
12
star
15

nanotest_extensions

Nano extensions for nanotest
Ruby
8
star
16

rack-supported-media-types

Rack middleware to specify an app's supported media types.
Ruby
7
star
17

override

Like #alias_method_chain, but awesome
Ruby
6
star
18

simple_example

Add easy fancy-pants examples to your projects
Ruby
3
star
19

swap

Ruby lib that allows dynamically replacing and restoring methods
Ruby
3
star
20

merb-in-file-templates

Define views right in your controller's file
Ruby
2
star
21

merb_simple_views

Merb plugin that allows defining templates (views, css, js)in the same file as the controller.
Ruby
2
star
22

tmptation

Classes that help safely manipulate temporary files and directories
Ruby
1
star
23

ntest

a little node.js test framework i wrote to learn the ropes.
JavaScript
1
star
24

rack-js4xhr

Rack middleware to set application/javascript media type on xhr requests.
Ruby
1
star