cinchrb / cinch

The IRC Bot Building Framework
http://www.rubydoc.info/gems/cinch
MIT License
1k stars 180 forks source link

Example of writing tests #52

Closed docwhat closed 12 years ago

docwhat commented 12 years ago

It would be nice to have an example for writing tests for a cinch-bot. Preferably in rspec, but anything would be nice.

dominikh commented 12 years ago

If you want RSpec, you'll have to wait for someone else, I won't touch it :)

Regarding tests in general: There's not much advice I can give here. Some users have tried to write tests for their bots, but other than having separate methods for computations and the actual sending back to the server, there's not much to be done at the moment. Cinch doesn't offer any tools or mocks or anything for writing tests for bots.

docwhat commented 12 years ago

Re: RSpec -- Fair enough. Though I'd be interested in why you don't like it.

Re: tests -- Have you considered creating a mock framework for it? Using mocha or some other stand-alone mock framework? I have had bugs with my bot where the match was wrong or something else like that and I'd really like to be able to assure that it doesn't happen again.

It would also alleviate the problem of how to test bots for a private network. Yeah, I could use the real system or start a localhost private IRC server....but I'd rather not. Plus it prevents continuous integration. I'd like other developers to contribute as well.

dominikh commented 12 years ago

Let's put it this way: the upcoming releases will provide a proper API for accessing plugin information, so getting a list of matchers, e.g., will be easily possible, so writing a test "framework" for Cinch shouldn't be too hard in the future. We're still working on emulating the IRC part though.

Regarding RSpec: It's an attempt of emulating English that went horribly wrong and the whole notion of writing tests in RSpec feels unnatural and unnecessarily painful. Imho.