Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Add spec for inline failing ruby call, gh-42
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Mar 2, 2020
1 parent 7bf215d commit c27c571
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions spec/rfunctions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
end
end

describe 'calling a Ruby function from Lua' do
context 'calling a Ruby function from Lua' do

it 'may return a single value' do

Expand Down Expand Up @@ -157,17 +157,6 @@
)
end

it 'raise exceptions (Ruby -> Lua -> Ruby and back)' do

@s.function :do_fail do
raise 'fail!'
end

expect(lambda {
@s.eval('return do_fail()')
}).to raise_error(RuntimeError)
end

it 'counts the animals correctly' do

@s.function 'key_up' do |table|
Expand Down Expand Up @@ -291,5 +280,44 @@
expect(@s.instance_variable_get(:@callbacks).size).to eq 1
end
end

context 'Ruby functions and exceptions' do

it 'raises exceptions (Ruby -> Lua -> Ruby and back)' do

@s.function :do_fail do
raise 'fail!'
end

expect {
@s.eval('return do_fail()')
}.to raise_error(RuntimeError)
end

it 'raises exceptions (Ruby -> Lua -> Ruby and back)' do

@s.function :do_fail do
raise 'fail!'
end

expect {
@s.eval('do_fail()')
}.to raise_error(RuntimeError)
end

it 'raises exceptions (gh-42)' do

@s.function :no_fail do
1
end
@s.function :do_fail do
raise 'fail!'
end

expect {
@s.eval('do_fail(); no_fail()')
}.to raise_error(RuntimeError)
end
end
end

0 comments on commit c27c571

Please sign in to comment.