Giter VIP home page Giter VIP logo

holygrail's Introduction

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

holygrail's People

Contributors

mynyml avatar bmaddy avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

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.