RSpec tips #2
RSpec and state_machine gem
Wanna test some `after_transition` or `before_transition` code from your models on RSpec without super complicated mocks and stubs? Worry no more, here’s the real deal!
# User model
after_transition on: :register, :give_gift
# User spec
it ‘gives gift to user after registering’ do
user = User.new
transition = StateMachine::Transition.new(user, User.state_machine, :register, :pending, :registered)
Now go test some transitions!