How to write unit tests for rules