Sha256: 2524ec6b598a54314903efe973a850704ab02e8556e412d96306408e97ed56d6
Contents?: true
Size: 1.05 KB
Versions: 14
Compression:
Stored size: 1.05 KB
Contents
require_relative '../../test_helper' class EventWithMarshallingTest < StateMachinesTest def setup @klass = Class.new do def save true end end self.class.const_set('Example', @klass) @machine = StateMachines::Machine.new(@klass, action: :save) @machine.state :parked, :idling @machine.events << @event = StateMachines::Event.new(@machine, :ignite) @event.transition(parked: :idling) @object = @klass.new @object.state = 'parked' end def test_should_marshal_during_before_callbacks @machine.before_transition { |object, _transition| Marshal.dump(object) } @event.fire(@object) end def test_should_marshal_during_action @klass.class_eval do remove_method :save def save Marshal.dump(self) end end @event.fire(@object) end def test_should_marshal_during_after_callbacks @machine.after_transition { |object, _transition| Marshal.dump(object) } @event.fire(@object) end def teardown self.class.send(:remove_const, 'Example') end end
Version data entries
14 entries across 14 versions & 2 rubygems