mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
f14180707d
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
33 lines
659 B
Ruby
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
|
|
|