1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

add specs for type conversion

This commit is contained in:
Charles Lowell 2009-10-14 22:51:50 -05:00
parent bae75cbd1b
commit fabd535875
3 changed files with 42 additions and 0 deletions

1
spec/spec.opts Normal file
View file

@ -0,0 +1 @@
--colour

10
spec/spec_helper.rb Normal file
View file

@ -0,0 +1,10 @@
begin
require 'spec'
rescue LoadError
require 'rubygems' unless ENV['NO_RUBYGEMS']
gem 'rspec'
require 'spec'
end
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'v8'

31
spec/therubyracer_spec.rb Normal file
View file

@ -0,0 +1,31 @@
require File.dirname(__FILE__) + '/spec_helper.rb'
describe "The Ruby Racer" do
before(:each) do
@cxt = V8::Context.new
end
describe "Type Conversion from Ruby to Javascript" do
it "can pass strings back to ruby" do
eval("'Hello World'").should == "Hello World"
end
it "can pass numbers back to ruby" do
eval("1").should == 1
eval("2.5").should == 2.5
end
it "can pass boolean values back to ruby" do
eval("true").should be(true)
eval("false").should be(false)
end
end
def eval(str)
@cxt.eval(str)
end
end