Wisper::MiniTest
MiniTest assertions/expectations and stubbing for Wisper. Based on @krisleech work and his own wisper-rspec gem.
Installation
gem 'wisper-minitest', require: false
Usage
Broadcast assertion
In test_helper
require 'wisper/minitest/assertions'
In your tests:
assert_broadcast(:an_event) { publisher.execute }
This will match both broadcast(:an_event)
and broadcast(:an_event, :arg_1)
.
# with optional arguments
assert_broadcast(:another_event, :arg1, :arg2) { publisher.execute }
With event arguments, it matches only if the event is broadcast with those
arguments. This assertion matches broadcast(:another_event, :arg1, :arg2)
but
not broadcast(:another_event)
.
Todo
The wisper-rspec gem is not fully ported yet. Here's what's missing:
- Convert
broadcast
expectation toassert_broadcast
assertion - Add a
refute_broadcast
assertion - Make those available as Minitest expectations too
- Document or implement a way to assert that a listener is receiving events
- Port publisher stub feature
Contributing
Any contribution is welcome! Open an issue or send a pull request to get started.