1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/win32ole/tests/testOLEEVENT.rb
suke f14180707d merge win32ole from rough
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-01 12:34:30 +00:00

33 lines
659 B
Ruby

require 'rubyunit'
require 'win32ole'
class TestWIN32OLE_EVENT < RUNIT::TestCase
def setup
@excel = WIN32OLE.new("Excel.Application")
@excel.visible = true
end
def test_on_event
book = @excel.workbooks.Add
value = ""
begin
ev = WIN32OLE_EVENT.new(book, 'WorkbookEvents')
ev.on_event('SheetChange'){|arg1, arg2|
begin
value = arg1.value
rescue
value = $!.message
end
}
book.Worksheets(1).Range("A1").value = "OK"
ensure
book.saved = true
end
assert_equal("OK", value)
end
def teardown
@excel.quit
@excel = nil
GC.start
end
end