summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-09 10:12:11 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-09 10:12:11 +0200
commit8a600d5815fb2a44fd9d993c85b43edb7ea1dc8c (patch)
tree4db8a6446f05694e0a1ed45763c58cf05d4ce73a
parentde06e689343187e9f932c07325194edce1f19a88 (diff)
downloadedoors-ruby-8a600d5815fb2a44fd9d993c85b43edb7ea1dc8c.zip
edoors-ruby-8a600d5815fb2a44fd9d993c85b43edb7ea1dc8c.tar.gz
specs: increase Room#send_p coverage
-rw-r--r--spec/evendoors_spec.rb53
1 files changed, 50 insertions, 3 deletions
diff --git a/spec/evendoors_spec.rb b/spec/evendoors_spec.rb
index 7fff64b..19e56b4 100644
--- a/spec/evendoors_spec.rb
+++ b/spec/evendoors_spec.rb
@@ -510,15 +510,25 @@ describe EvenDoors do
room0 = EvenDoors::Room.new 'room0', nil
room1 = EvenDoors::Room.new 'room1', room0
p = EvenDoors::Twirl.require_p EvenDoors::Particle
- p.src = Fake.new
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
- p.dst.should be p.src
+ p.dst.should be room1.space
+ end
+ #
+ it "routing success (direct)" do
+ room0 = EvenDoors::Room.new 'room0', nil
+ door0 = EvenDoors::Door.new 'door0', room0
+ p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p.src = Fake.new
+ p.set_dst! 'get', 'door0'
+ room0.send_p p
+ p.action.should eql 'get'
+ p.dst.should be door0
end
#
- it "routeting success" do
+ it "routing success (bubble up the direct door)" do
room0 = EvenDoors::Room.new 'room0', nil
room1 = EvenDoors::Room.new 'room1', room0
door0 = EvenDoors::Door.new 'door0', room0
@@ -530,6 +540,43 @@ describe EvenDoors do
p.dst.should be door0
end
#
+ it "route error: right room, no drill down (2xbubble up)" do
+ room0 = EvenDoors::Room.new 'room0', nil
+ room1 = EvenDoors::Room.new 'room1', room0
+ room2 = EvenDoors::Room.new 'room2', room0
+ room3 = EvenDoors::Room.new 'room3', room2
+ door0 = EvenDoors::Door.new 'door01', room1
+ p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p.src = Fake.new
+ p.set_dst! 'get', 'room0/room1/door01'
+ room3.send_p p
+ p.action.should eql EvenDoors::ACT_ERROR
+ p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_RRNDD
+ p.dst.should be p.src
+ end
+ #
+ it "routing success: no door name -> src" do
+ room0 = EvenDoors::Room.new 'room0', nil
+ door0 = EvenDoors::Door.new 'door0', room0
+ p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p.src = door0
+ p.set_dst! 'get'
+ room0.send_p p
+ p.action.should eql 'get'
+ p.dst.should be door0
+ end
+ #
+ it "routing success: no door name -> src" do
+ room0 = EvenDoors::Room.new 'room0', nil
+ door0 = EvenDoors::Door.new 'door0', room0
+ p = EvenDoors::Twirl.require_p EvenDoors::Particle
+ p.set_dst! 'get'
+ room0.send_p p
+ p.action.should eql EvenDoors::ACT_ERROR
+ p[EvenDoors::ERROR_FIELD].should eql EvenDoors::ERROR_ROUTE_NDNS
+ p.dst.should be room0.space
+ end
+ #
#
end
end