diff options
-rw-r--r-- | spec/evendoors_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
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 |