isaac icon indicating copy to clipboard operation
isaac copied to clipboard

mock_bot rewritten to pass tests with Eventmachine backend

Open ericgj opened this issue 14 years ago • 1 comments

I redesigned mock_bot to work with Eventmachine, so the tests pass, with minimal changes. See what you think.

  • I made one small change to the code, to split the IRC < EM::Connection class from the methods that get mixed into the connection: this made it easier to test these methods in isolation from the EM reactor.
  • Because the whole reactor is stubbed out when you use mock_bot, any time your tests write to the @server (simulating a response from the server), you have to manually call receive_data with the contents of the @socket. Luckily, most of the server responses we care about are done in one place, bot_is_connected. You may find a better way to do this than I did. It's a little like a hand-cranked car, but it works :)

Thanks for a great little tool and excellent code BTW - learned a lot reading it.

ericgj avatar Feb 26 '11 05:02 ericgj

PS. the commit to pull from is a44fda2. The further commits listed above are for features I've started to add to my fork - namely, ability to configure bots from external file; and ability to auto-join channels. If you like I can submit pull requests for these feature branches separately (I've added tests for them and they all pass).

ericgj avatar Feb 27 '11 22:02 ericgj