[rspec-users] [Q] testing WIN32OLE_EVENT callbacks

Chuck Remes
Wed, 26 Aug 2009 18:57:35 -0000

I''m trying to setup some specs (really just assertions) that verify
some callbacks are executed in response to COM events. In the
WIN32OLE_EVENT class you may subscribe to a COM event and have it
delivered to you for processing. Syntax looks like:

               event_handler.on_event(''StartEvent'') do |*args|
                 do_start_event args
               end

The #do_start_event method is a member of the containing class. The
only way I can confirm that it is being called is to set an
expectation on the class under test. I''ve always noted that mocking/
stubbing the class under test is rather bad form. Regardless, I don''t
know how to "mock" the delivery of an event anyway so this may all be
moot.

I searched the list archives for ''win32ole'' back to early 2007
and
came up with 0 hits. Any suggestions on how to tackle this?

cr