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:
parent
bae75cbd1b
commit
fabd535875
3 changed files with 42 additions and 0 deletions
1
spec/spec.opts
Normal file
1
spec/spec.opts
Normal file
|
@ -0,0 +1 @@
|
|||
--colour
|
10
spec/spec_helper.rb
Normal file
10
spec/spec_helper.rb
Normal 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
31
spec/therubyracer_spec.rb
Normal 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
|
Loading…
Add table
Reference in a new issue