Closed ka8725 closed 10 years ago
it should be trivial to write a matcher for that. reflection is possible on the entire state machine. you can access available transitions via class.state_machines[:machine_name].events[:event_name].branches
Do note that fields != machines. as multiple machines can access the same attribute.
And wouldn't it be better to actually test the transition performing correctly, including side-effects instead of just checking whether it's declared? If you simply check the existence you're basically writing down the same definitions twice (once in the state_machine DSL, once in the tests). I.e. you only end up testing whether the state_machine DSL "works".
Thanks for the tip, you are right about checking real states changes
It would be great to have some DSL to test the defined state machine on the model. For example, in our project there is a custom matcher which allows to test the states like this:
If you are interested in this solution I'm ready to contribute this feature. Please, let me know. Thanks