-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from sobrinho/master
Add tests
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,3 @@ source "http://rubygems.org" | |
|
||
# Specify your gem's dependencies in furnace.gemspec | ||
gemspec | ||
gem 'hanna-nouveau' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'rlua' | ||
|
||
describe Lua::State do | ||
context 'ruby' do | ||
it 'creates a variable in Ruby and pass it to Lua' do | ||
subject.value = 10 | ||
|
||
subject.__eval 'value = value * 2' | ||
|
||
expect(subject.value).to eq 20 | ||
end | ||
|
||
it 'creates a table in Ruby and pass it to Lua' do | ||
subject.ruby = { | ||
'meaning_of_life' => 42, | ||
'zaphod' => lambda { |table| p "Meaning of life: #{table.meaning_of_life}" } | ||
} | ||
|
||
expect { subject.__eval "ruby:zaphod()" }.to output("\"Meaning of life: 42.0\"\n").to_stdout | ||
end | ||
end | ||
|
||
describe 'lua' do | ||
it 'creates a variable in Lua and pass it to Ruby' do | ||
subject.__eval 'value = 15' | ||
|
||
expect(subject.value).to eq 15 | ||
end | ||
|
||
it 'creates a function in Lua and launch it from Ruby' do | ||
subject.__eval "ran = false" | ||
subject.__eval "function lua_func() ran = true end" | ||
|
||
expect(subject.ran).to be_falsey | ||
|
||
subject.lua_func | ||
|
||
expect(subject.ran).to be_truthy | ||
end | ||
end | ||
end |