Skip to content

Tool to maps Ruby RSpec tests into a native Javascript application in order to be able to drive multiple (sequential or parallel) builds using an overlapping test suite.

cjkula/stunt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://rubygems.org/gems/stunt

gem install stunt --pre

Maps Ruby object method chain addressing into corresponding JavaScript method chains.

require 'stunt'

class MyClass
  def some_method
    'result'
  end
end

Stunt::Javascript.map!(MyClass)

describe "MyClass in JavaScript" do
	it "should get 'result'" do
		MyClass.new.some_method.should == 'result'
	end
end

The test reads normally in Ruby, but behind the curtains, Stunt calls the Javascript constructor for MyClass, stores and returns a reference to that object, and then evaluates its corresponding method, i.e.

window.TestObjects[0] = new MyClass();  // the index is returned and tracked in the Ruby proxy object
// ...
window.TestObjects[0].someMethod();     // underscore notation is translated to JavaScript-style names

A whole lotta convention over configuration going on here. : )

This started off as a tool to assist in the development of Cipher (https://github.com/cjkula/cipher-lang), but I hope that others might be able to get some use out of it for different purposes.

About

Tool to maps Ruby RSpec tests into a native Javascript application in order to be able to drive multiple (sequential or parallel) builds using an overlapping test suite.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages