Harmony: JavaScript And A DOM Environment In Ruby
Harmony, from Martin Aumont, is a new Ruby DSL for executing JavaScript and DOM-using code from within Ruby apps. Why's that cool? Well, it enables you to build your own Ruby-level unit tests for JavaScript code within your Web applications - everything can be under one set of test suites!
Harmony sounds like a significant piece of engineering, but really it's a wrapper that stands on the shoulder of giants in the form of Johnson, which provides the Mozilla Spidermonkey Javascript runtime to Ruby, and env.js, a DOM environment recreated in JavaScript.
Harmony's "Hello World" example:
HolyGrail: The Rails Plugin
If you're using Rails, HolyGrail is a plugin that brings the power of Harmony to your apps (so far in functional tests only). Some example tests with HolyGrail:
Note: This Harmony is not to be confused with the awesome Harmony CMS that esteemed Rubyist John Nunemaker is working on..
February 17, 2010 at 2:57 am
I'm using it for a project of mine, as a way to be able to stay within RSpec land and test JS without relying on Selenium.
http://github.com/juliocesar/shining/blob/master/spec/shining_spec.rb
If like me you're planning on writing tests/specs with harmony in the form of a local page acting as a fixture that includes some Javascript in the head, you might want to use Harmony::Page.fetch and pass a file URI (file:///) as a parameter.
February 18, 2010 at 6:15 pm
Thanks for sharing that, Julio! Having an RSpec example suddenly makes Harmony a LOT more interesting to me.
February 22, 2010 at 4:44 am
Thank you very much for your example of using Ruby as a DSL
Cheers
george
http://www.rubyinside.com/
February 22, 2010 at 4:45 am
did my comments go in?
February 22, 2010 at 4:46 am
did my comment go in?
February 26, 2010 at 7:48 pm
Does Harmony handle AJAX, Events and other asynchronous?
March 19, 2010 at 12:39 am
Thanks for the example, oh and George your comment went in!!!