I have a state machine with some guards to prevent special state transitions. In my spec, I'm trying to expect guard violation error like this:
expect(violate_guard).to raise_exception
As a result, I receive correct error in my spec test:
Failure/Error: expect(my_model.change_event).to raise_exception AASM::InvalidTransition: Event 'change_event' cannot transition from 'current_state'
I'm wondering how should I change my spec to have a satisfied test?
you could try:
expect { violate_guard }.to raise_error