Sha256: 324b390c09088604d2a824e29bacc4903ebc328afab3572f0155e6d93061be4b
Contents?: true
Size: 1.94 KB
Versions: 9
Compression:
Stored size: 1.94 KB
Contents
Given(/^I have an Auton that holds counter state$/) do class CounterAuton include StructureMapper::Hash def initialize self.counter = 0 end def next self.counter += 1 end attribute counter: Fixnum end @counter_auton_type="CounterAuton" @counter_auton_id = Celluloid::Actor[:nestene_core].create_auton(@counter_auton_type, "counter") end Given(/^I have an Auton that schedules a callback step on the counter Auton$/) do class CallbackAuton include StructureMapper::Hash def start self.context.schedule_callback('counter', :next, [], :set_state) end def set_state new_state self.state = new_state end def set_state_error error_type, message self.error = message end attr_accessor :context attribute state: Fixnum attribute error: String end @callback_auton_type="CallbackAuton" @callback_auton_id = Celluloid::Actor[:nestene_core].create_auton(@callback_auton_type, "callback") end When(/^I execute second Auton's schedule step$/) do Celluloid::Actor[:nestene_core].schedule_step @callback_auton_id, :start end Then(/^the callback step of the second Auton should be executed$/) do sleep 0.1 expect(Celluloid::Actor["storage:%s" % @callback_auton_id].get.serialized['state']).to eq(1) end Given(/^I have an Auton that hold counter state and raises exception on execution$/) do class FailingCounterAuton include StructureMapper::Hash def initialize self.counter = 0 end def next raise "some exception" end attribute counter: Fixnum end @counter_auton_type="FailingCounterAuton" @counter_auton_id = Celluloid::Actor[:nestene_core].create_auton(@counter_auton_type, "counter") end Then(/^the callback error step of the second Auton with the exception's message should be executed$/) do sleep 0.1 expect(Celluloid::Actor["storage:%s" % @callback_auton_id].get.serialized['error']).to eq('some exception') end
Version data entries
9 entries across 9 versions & 1 rubygems