summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-09 00:09:10 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-09 00:09:10 +0200
commit1b72a2a782d255ff57899b0d30e494faa42c0b40 (patch)
treeb41a9770d614c5ce22b2d4d28d5cd2bc846dbc9b
parentb312a413d63a25f6993350915177982fe9e92197 (diff)
downloadedoors-ruby-1b72a2a782d255ff57899b0d30e494faa42c0b40.zip
edoors-ruby-1b72a2a782d255ff57899b0d30e494faa42c0b40.tar.gz
specs, cover Room, basic error and success
-rw-r--r--spec/evendoors_spec.rb58
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