From 1b72a2a782d255ff57899b0d30e494faa42c0b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 9 May 2012 00:09:10 +0200 Subject: specs, cover Room, basic error and success --- spec/evendoors_spec.rb | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/spec/evendoors_spec.rb b/spec/evendoors_spec.rb index 7c8438a..82d9809 100644 --- a/spec/evendoors_spec.rb +++ b/spec/evendoors_spec.rb @@ -449,5 +449,63 @@ describe EvenDoors do r2.space.should be s end # + it "route error: no destination no source" do + room = EvenDoors::Room.new 'room', nil + p = EvenDoors::Twirl.require_p EvenDoors::Particle + room.send_p p + p.action.should eql EvenDoors::ACT_ERROR + p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_NDNS + end + # + it "route error: no destination no links" do + room = EvenDoors::Room.new 'room', nil + p = EvenDoors::Twirl.require_p EvenDoors::Particle + p.src = Fake.new + room.send_p p + p.action.should eql EvenDoors::ACT_ERROR + p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_NDNL + end + # + it "route error: top room, wrong room" do + room0 = EvenDoors::Room.new 'room0', nil + room1 = EvenDoors::Room.new 'room1', room0 + p = EvenDoors::Twirl.require_p EvenDoors::Particle + p.set_dst! 'get', 'noroom/door' + room1.send_p p + p.action.should eql EvenDoors::ACT_ERROR + p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_TRWR + end + # + it "route error: right room, wrong door" do + room = EvenDoors::Room.new 'room', nil + p = EvenDoors::Twirl.require_p EvenDoors::Particle + p.set_dst! 'get', 'room/nodoor' + room.send_p p + p.action.should eql EvenDoors::ACT_ERROR + p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_RRWD + end + # + it "route error: right room, wrong door (bubble up)" do + room0 = EvenDoors::Room.new 'room0', nil + room1 = EvenDoors::Room.new 'room1', room0 + p = EvenDoors::Twirl.require_p EvenDoors::Particle + p.set_dst! 'get', 'room0/nodoor' + room1.send_p p + p.action.should eql EvenDoors::ACT_ERROR + p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_RRWD + end + # + it "routeting success" do + room0 = EvenDoors::Room.new 'room0', nil + room1 = EvenDoors::Room.new 'room1', room0 + door0 = EvenDoors::Door.new 'door0', room0 + p = EvenDoors::Twirl.require_p EvenDoors::Particle + p.set_dst! 'get', 'room0/door0' + room1.send_p p + p.action.should eql 'get' + p.dst.should be door0 + end + # + # end end -- cgit v1.1-2-g2b99