jbarnette / johnson

Johnson wraps JavaScript in a loving Ruby embrace.

This URL has Read+Write access

johnson / test / johnson_test.rb
100644 17 lines (13 sloc) 0.49 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
 
class JohnsonTest < Test::Unit::TestCase
  def test_shortcut_evaluate
    assert_equal(4, Johnson.evaluate("2 + 2"))
  end
  
  def test_can_provide_context_vars_to_evaluate
    assert_equal(4, Johnson.evaluate("2 + foo", :foo => 2))
  end
  
  def test_evaluate_uses_a_new_runtime_each_time
    assert_equal(4, Johnson.evaluate("foo", :foo => 4))
    assert_raise(Johnson::Error) { Johnson.evaluate("foo") }
  end
end