From 2a461e013ed0dfe7601292d71b080d83b8edcbf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 2 Jun 2012 21:55:54 +0200 Subject: specs follow Particle#set_dst! -> Particle#add_dst --- spec/board_spec.rb | 4 ++-- spec/door_spec.rb | 12 +++++++---- spec/particle_spec.rb | 58 +++++++++++++++++++++++++++++---------------------- spec/room_spec.rb | 22 +++++++++---------- spec/spin_spec.rb | 4 ++-- 5 files changed, 56 insertions(+), 44 deletions(-) diff --git a/spec/board_spec.rb b/spec/board_spec.rb index b533b23..d549530 100644 --- a/spec/board_spec.rb +++ b/spec/board_spec.rb @@ -68,9 +68,9 @@ describe Iotas::Board do b0.process_p p0 p0.merged(0).should be_nil # need to set it to p0 too, so case in Board0 is ok - p0.set_dst! Iotas::ACT_FOLLOW + p0.add_dst Iotas::ACT_FOLLOW p0.split_dst! - p1.set_dst! Iotas::ACT_FOLLOW + p1.add_dst Iotas::ACT_FOLLOW p1.split_dst! b0.process_p p1 b0.ok.should be_true diff --git a/spec/door_spec.rb b/spec/door_spec.rb index 3d93518..b836786 100644 --- a/spec/door_spec.rb +++ b/spec/door_spec.rb @@ -55,27 +55,31 @@ describe Iotas::Door do d0 = Door0.new 'door0', f p0 = d0.require_p Iotas::Particle # - p0.set_dst! 'SEND' + p0.add_dst 'SEND' p0.split_dst! d0.process_p p0 f.p.should eql p0 + p0.clear_dsts! # - p0.set_dst! 'SEND_SYS' + p0.add_dst 'SEND_SYS' p0.split_dst! d0.process_p p0 f.sp.should eql p0 + p0.clear_dsts! # - p0.set_dst! 'RELEASE' + p0.add_dst 'RELEASE' p0.split_dst! d0.process_p p0 p1 = d0.require_p Iotas::Particle p1.should be p0 + p0.clear_dsts! # - p0.set_dst! 'LOST' + p0.add_dst 'LOST' p0.split_dst! d0.process_p p0 p1 = d0.require_p Iotas::Particle p1.should be p0 + p0.clear_dsts! # d0.process_sys_p p0 p1 = @spin.require_p Iotas::Particle diff --git a/spec/particle_spec.rb b/spec/particle_spec.rb index 4952000..0a7f095 100644 --- a/spec/particle_spec.rb +++ b/spec/particle_spec.rb @@ -80,52 +80,60 @@ describe Iotas::Particle do # it "wrong path should raise exeption" do p = Iotas::Particle.new - lambda { p.set_dst! 'action', '/room' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! 'action', 'room/' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! '', 'room/' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! 'action', 'room//door' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! ' ' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! ' ', '' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! 'f f' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! '', ' d' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! '' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! '', '' }.should raise_error(Iotas::Exception) - lambda { p.set_dst! nil }.should raise_error(TypeError) - lambda { p.set_dst! 'action', nil }.should raise_error(NoMethodError) + lambda { p.add_dst 'action', '/room' }.should raise_error(Iotas::Exception) + lambda { p.add_dst 'action', 'room/' }.should raise_error(Iotas::Exception) + lambda { p.add_dst '', 'room/' }.should raise_error(Iotas::Exception) + lambda { p.add_dst 'action', 'room//door' }.should raise_error(Iotas::Exception) + lambda { p.add_dst ' ' }.should raise_error(Iotas::Exception) + lambda { p.add_dst ' ', '' }.should raise_error(Iotas::Exception) + lambda { p.add_dst 'f f' }.should raise_error(Iotas::Exception) + lambda { p.add_dst '', ' d' }.should raise_error(Iotas::Exception) + lambda { p.add_dst '' }.should raise_error(Iotas::Exception) + lambda { p.add_dst '', '' }.should raise_error(Iotas::Exception) + lambda { p.add_dst nil }.should raise_error(TypeError) + lambda { p.add_dst 'action', nil }.should raise_error(NoMethodError) end # - it "routing: set_dst! and split_dst!" do + it "routing: add_dst and split_dst!" do p = Iotas::Particle.new d0 = Iotas::Door.new 'door0', nil # - p.set_dst! 'action', 'room0/room1/door' + p.split_dst! + p.room.should be_nil + p.door.should be_nil + p.action.should be_nil + # + p.add_dst 'action', 'room0/room1/door' p.split_dst! p.room.should eql 'room0/room1' p.door.should eql 'door' p.action.should eql 'action' + p.clear_dsts! # - p.set_dst! 'action', 'room/door' + p.add_dst 'action', 'room/door' p.split_dst! p.room.should eql 'room' p.door.should eql 'door' p.action.should eql 'action' + p.clear_dsts! # - p.set_dst! 'action', '' + p.add_dst 'action', '' p.split_dst! - p.room.should eql nil - p.door.should eql nil + p.room.should be_nil + p.door.should be_nil p.action.should eql 'action' + p.clear_dsts! # - p.set_dst! 'action' + p.add_dst 'action' p.split_dst! - p.room.should eql nil - p.door.should eql nil + p.room.should be_nil + p.door.should be_nil p.action.should eql 'action' - # p.clear_dsts! + # p.add_dsts 'door?action,?action' p.split_dst! - p.room.should eql nil + p.room.should be_nil p.door.should eql 'door' p.action.should eql 'action' # @@ -133,8 +141,8 @@ describe Iotas::Particle do # p.dst.should be d0 p.split_dst! - p.room.should eql nil - p.door.should eql nil + p.room.should be_nil + p.door.should be_nil p.action.should eql 'action' # end diff --git a/spec/room_spec.rb b/spec/room_spec.rb index 3f62681..98f2e49 100644 --- a/spec/room_spec.rb +++ b/spec/room_spec.rb @@ -63,7 +63,7 @@ describe Iotas::Room do door0 = Iotas::Door.new 'door0', room0 p = @spin.require_p Iotas::Particle p.init! Fake.new( 'fake', @spin) - p.set_dst! 'get', 'door0' + p.add_dst 'get', 'door0' room0.send_p p p.action.should eql 'get' p.dst.should be door0 @@ -75,7 +75,7 @@ describe Iotas::Room do door0 = Iotas::Door.new 'door0', room1 p = @spin.require_p Iotas::Particle p.init! Fake.new('fake', @spin) - p.set_dst! 'get', 'dom0/room0/room1/door0' + p.add_dst 'get', 'dom0/room0/room1/door0' room0.send_p p p.action.should eql 'get' p.dst.should be door0 @@ -84,7 +84,7 @@ describe Iotas::Room do it "route error: no source" do room = Iotas::Room.new 'room', @spin p = @spin.require_p Iotas::Particle - p.set_dst! 'get', 'room/door' + p.add_dst 'get', 'room/door' room.send_p p p.action.should eql Iotas::ACT_ERROR p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_NS @@ -105,7 +105,7 @@ describe Iotas::Room do room0 = Iotas::Room.new 'room0', @spin p = @spin.require_p Iotas::Particle p.init! Fake.new('fake', @spin) - p.set_dst! 'get', 'nodoor' + p.add_dst 'get', 'nodoor' room0.send_p p p.action.should eql Iotas::ACT_ERROR p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_RRWD @@ -116,7 +116,7 @@ describe Iotas::Room do room0 = Iotas::Room.new 'room0', @spin p = @spin.require_p Iotas::Particle p.init! Fake.new('fake', @spin) - p.set_dst! 'get', 'dom0/room0/nodoor' + p.add_dst 'get', 'dom0/room0/nodoor' room0.send_p p p.action.should eql Iotas::ACT_ERROR p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_RRWD @@ -128,7 +128,7 @@ describe Iotas::Room do room1 = Iotas::Room.new 'room1', room0 p = @spin.require_p Iotas::Particle p.init! Fake.new('fake', room0) - p.set_dst! 'get', 'dom0/room0/nodoor' + p.add_dst 'get', 'dom0/room0/nodoor' room1.send_p p p.action.should eql Iotas::ACT_ERROR p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_DNE @@ -140,7 +140,7 @@ describe Iotas::Room do room1 = Iotas::Room.new 'room1', room0 p = @spin.require_p Iotas::Particle p.init! Fake.new('fake', @spin) - p.set_dst! 'get', 'dom0/noroom/fake' + p.add_dst 'get', 'dom0/noroom/fake' room1.send_p p p.action.should eql Iotas::ACT_ERROR p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_DNE @@ -152,7 +152,7 @@ describe Iotas::Room do door0 = Iotas::Door.new 'door0', room0 p = @spin.require_p Iotas::Particle p.init! door0 - p.set_dst! 'get' + p.add_dst 'get' room0.send_p p p.action.should eql 'get' p.dst.should be door0 @@ -224,7 +224,7 @@ describe Iotas::Room do it "system routing success: action only" do room0 = Iotas::Room.new 'room0', @spin p = @spin.require_p Iotas::Particle - p.set_dst! Iotas::SYS_ACT_ADD_LINK + p.add_dst Iotas::SYS_ACT_ADD_LINK room0.send_sys_p p p.action.should eql Iotas::SYS_ACT_ADD_LINK p.dst.should be room0.spin @@ -234,7 +234,7 @@ describe Iotas::Room do room0 = Iotas::Room.new 'room0', @spin door0 = Iotas::Door.new 'door0', room0 p = @spin.require_p Iotas::Particle - p.set_dst! Iotas::SYS_ACT_ADD_LINK, 'dom0/room0/door0' + p.add_dst Iotas::SYS_ACT_ADD_LINK, 'dom0/room0/door0' room0.send_sys_p p p.action.should eql Iotas::SYS_ACT_ADD_LINK p.dst.should be door0 @@ -250,7 +250,7 @@ describe Iotas::Room do p0.set_data Iotas::LNK_FIELDS, 'fields' p0.set_data Iotas::LNK_CONDF, 'f0,f1' p0.set_data Iotas::LNK_CONDV, 'v0v1' - p0.set_dst! Iotas::SYS_ACT_ADD_LINK, room0.path + p0.add_dst Iotas::SYS_ACT_ADD_LINK, room0.path room0.send_sys_p p0 @spin.spin! p = @spin.require_p Iotas::Particle diff --git a/spec/spin_spec.rb b/spec/spin_spec.rb index aba79a8..69266e5 100644 --- a/spec/spin_spec.rb +++ b/spec/spin_spec.rb @@ -76,7 +76,7 @@ describe Iotas::Spin do it "process_sys" do spin = Iotas::Spin.new 'dom0' p0 = spin.require_p Iotas::Particle - p0.set_dst! 'unknown' + p0.add_dst 'unknown' spin.send_sys_p p0 spin.spin! p1 = spin.require_p Iotas::Particle @@ -116,7 +116,7 @@ describe Iotas::Spin do it "hibernate! resume!" do spin = Iotas::Spin.new 'dom0' p0 = spin.require_p Iotas::Particle - p0.set_dst! Iotas::SYS_ACT_HIBERNATE + p0.add_dst Iotas::SYS_ACT_HIBERNATE spin.send_sys_p p0 spin.spin! dom0 = Iotas::Spin.resume! spin.hibernate_path -- cgit v1.1-2-g2b99