The Ruby Racer gem embeds the V8 Javascript engine within Ruby. The obvious advantage of this being that Ruby's BDD/TDD frameworks can be used when developing Javascript.

For example, to use RSpec, start with the following folder structure:

example/
  js/
    advanced_maths.js
    hello.js
  spec/
    hello.rb
    spec_helper.rb

js/advanced_maths.js :

function addTwo(n)
{
  return n + 2;
}

js/hello.js :

function hello()
{
  return "hello world";
}

spec/spec_helper.rb defines a wrapper class for invoking simple Javascript functions:

require 'spec_helper'

describe "testing js with RSpec" do

  JS.setup_env(["hello.js",
                "advanced_maths.js"])

  it "returns hello from js" do
    JS.call(:hello).should == "hello world"
  end

  it "adds 2 to a number" do
    JS.call(:addTwo, 3).should == 5
  end
end

Run the specs with:

rspec spec/hello.rb
..

Finished in 0.00092 seconds
2 examples, 0 failures

This is a _very_ basic setup that should prove useful when developing my Javascript code especially once the JS class can deal with more complicated arguments