ruru::util::str_to_cstring; use std::ptr; extern fn rb_sum(_mod: Value, a :Value, b: Value) -> Value { let a = unsafe { fixnum::rb_num2int(a) as i64 }; let b = unsafe { fixnum::rb_num2int(b) as i64 }; let sum = a + b; unsafe { fixnum::rb_int2inum(sum as SignedValue) } } extern fn rb_call_to_s(_mod: Value, obj: Value) -> Value { unsafe { let method_id = util::rb_intern(str_to_cstring("to_s").as_ptr()); util::rb_funcallv(obj, method_id, 0, ptr::null()) } } 28
2 = 3" do expect(Wasabi.sum(1, 2)).to eq 3 end end describe '.call_to_s' do context 'class with :to_s defined' do subject do klass = Class.new klass.define_method(:to_s) { 'foo' } Wasabi.call_to_s(klass.new) end it { is_expected.to eq 'foo' } end end end 31