diff options
-rw-r--r-- | spec/board_spec.rb | 30 | ||||
-rw-r--r-- | spec/door_spec.rb | 20 | ||||
-rw-r--r-- | spec/iota_spec.rb | 20 | ||||
-rw-r--r-- | spec/link_spec.rb | 18 | ||||
-rw-r--r-- | spec/particle_spec.rb | 254 | ||||
-rw-r--r-- | spec/room_spec.rb | 152 | ||||
-rw-r--r-- | spec/spin_spec.rb | 44 |
7 files changed, 269 insertions, 269 deletions
diff --git a/spec/board_spec.rb b/spec/board_spec.rb index 554ede0..b3300f6 100644 --- a/spec/board_spec.rb +++ b/spec/board_spec.rb @@ -18,10 +18,10 @@ describe Edoors::Board do board = Edoors::Board.new 'hell', @spin p0 = board.require_p p1 = board.require_p Edoors::Particle - (p0===p1).should be_false + expect(p0===p1).to be_falsey board.release_p p0 p2 = board.require_p - (p0===p2).should be_true + expect(p0===p2).to be_truthy end # it "particle wait and merge" do @@ -30,13 +30,13 @@ describe Edoors::Board do p0['k1'] = 'neither' p0['k2'] = 'v2' p0.set_link_keys 'k0', 'k2' - p0.link_value.should == {'k0'=>'v0','k2'=>'v2'} + expect(p0.link_value).to be == {'k0'=>'v0','k2'=>'v2'} p1 = Edoors::Particle.new p1['k0'] = 'v0' p1['k1'] = 'nore' p1['k2'] = 'v2' p1.set_link_keys 'k0', 'k2' - p1.link_value.should == {'k0'=>'v0','k2'=>'v2'} + expect(p1.link_value).to be == {'k0'=>'v0','k2'=>'v2'} P0 = p0 P1 = p1 class Board0 < Edoors::Board @@ -58,27 +58,27 @@ describe Edoors::Board do end b0 = Board0.new 'door0', @spin b0.process_p p0 - p0.merged(0).should be_nil + expect(p0.merged(0)).to be_nil b0.process_p p1 - b0.ok.should be_true - b0.follow.should be_false + expect(b0.ok).to be_truthy + expect(b0.follow).to be_falsey # p1.merged_shift # b0.process_p p0 - p0.merged(0).should be_nil + expect(p0.merged(0)).to be_nil # need to set it to p0 too, so case in Board0 is ok p0.add_dst Edoors::ACT_FOLLOW p0.split_dst! p1.add_dst Edoors::ACT_FOLLOW p1.split_dst! b0.process_p p1 - b0.ok.should be_true - b0.follow.should be_true + expect(b0.ok).to be_truthy + expect(b0.follow).to be_truthy p2 = b0.require_p p2.set_dst! Edoors::ACT_PASS_THROUGH, b0 b0.process_p p2 - b0.pass_through.should be true + expect(b0.pass_through).to be true end # it "keep! and flush!" do @@ -100,9 +100,9 @@ describe Edoors::Board do p3 = Edoors::Particle.new p3.set_dst! Edoors::ACT_FOLLOW, b0 b0.process_p p3 - (b0.get({}).merged_length+1).should == 4 + expect(b0.get({}).merged_length+1).to be == 4 b0.flush! - b0.get({}).should be_nil + expect(b0.get({})).to be_nil end # it "board->json->board" do @@ -114,8 +114,8 @@ describe Edoors::Board do board.process_p p0 board.process_p p1 hell = Edoors::Board.json_create( JSON.load( JSON.generate(board) ) ) - board.name.should eql hell.name - JSON.generate(board).should eql JSON.generate(hell) + expect(board.name).to eql hell.name + expect(JSON.generate(board)).to eql JSON.generate(hell) end # end diff --git a/spec/door_spec.rb b/spec/door_spec.rb index d86bb5a..9f909a5 100644 --- a/spec/door_spec.rb +++ b/spec/door_spec.rb @@ -18,10 +18,10 @@ describe Edoors::Door do door = Edoors::Door.new 'hell', @spin p0 = door.require_p Edoors::Particle p1 = door.require_p - (p0===p1).should be_false + expect(p0===p1).to be_falsey door.release_p p0 p2 = door.require_p - (p0===p2).should be_true + expect(p0===p2).to be_truthy end # it "NoMethodError when receive_p not overridden" do @@ -30,7 +30,7 @@ describe Edoors::Door do f = Fake.new 'fake', @spin d0 = Door0.new 'door0', f p0 = d0.require_p Edoors::Particle - lambda { d0.process_p p0 }.should raise_error(NoMethodError) + expect(lambda { d0.process_p p0 }).to raise_error(NoMethodError) end # it "send_p, send_sys_p, release_p and release of lost particles" do @@ -55,39 +55,39 @@ describe Edoors::Door do p0.add_dst 'SEND' p0.split_dst! d0.process_p p0 - f.p.should eql p0 + expect(f.p).to eql p0 p0.clear_dsts! # p0.add_dst 'SEND_SYS' p0.split_dst! d0.process_p p0 - f.sp.should eql p0 + expect(f.sp).to eql p0 p0.clear_dsts! # p0.add_dst 'RELEASE' p0.split_dst! d0.process_p p0 p1 = d0.require_p - p1.should be p0 + expect(p1).to be p0 p0.clear_dsts! # p0.add_dst 'LOST' p0.split_dst! d0.process_p p0 p1 = d0.require_p Edoors::Particle - p1.should be p0 + expect(p1).to be p0 p0.clear_dsts! # d0.process_sys_p p0 p1 = @spin.require_p Edoors::Particle - p1.should be p0 + expect(p1).to be p0 end # it "door->json->door" do door = Edoors::Door.new 'hell', @spin hell = Edoors::Door.json_create( JSON.load( JSON.generate(door) ) ) - door.name.should eql hell.name - JSON.generate(door).should eql JSON.generate(hell) + expect(door.name).to eql hell.name + expect(JSON.generate(door)).to eql JSON.generate(hell) end # end diff --git a/spec/iota_spec.rb b/spec/iota_spec.rb index 787d007..d257285 100644 --- a/spec/iota_spec.rb +++ b/spec/iota_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Edoors::Iota do # it "path construction" do - class S<Edoors::Iota + class S < Edoors::Iota def add_iota s end end @@ -15,30 +15,30 @@ describe Edoors::Iota do s1 = S.new 'room0', s0 s2 = S.new 'room1', s1 s3 = S.new 'door', s2 - s3.path.should eql 'top/room0/room1/door' - lambda { Edoors::Iota.new('do/or0', nil) }.should raise_error(Edoors::Exception) - lambda { Edoors::Iota.new('/door0', nil) }.should raise_error(Edoors::Exception) - lambda { Edoors::Iota.new('door0/', nil) }.should raise_error(Edoors::Exception) + expect(s3.path).to eql 'top/room0/room1/door' + expect(lambda { Edoors::Iota.new('do/or0', nil) }).to raise_error(Edoors::Exception) + expect(lambda { Edoors::Iota.new('/door0', nil) }).to raise_error(Edoors::Exception) + expect(lambda { Edoors::Iota.new('door0/', nil) }).to raise_error(Edoors::Exception) end # it 'start! should do nothing' do - S.new('top', nil).start!.should be_nil + expect(S.new('top', nil).start!).to be_nil end # it 'stop! should do nothing' do - S.new('top', nil).stop!.should be_nil + expect(S.new('top', nil).stop!).to be_nil end # it 'hibernate! should return empty hash' do - S.new('top', nil).hibernate!.should be {} + expect(S.new('top', nil).hibernate!).to be {} end # it 'resume! should do nothing' do - S.new('top', nil).resume!(nil).should be_nil + expect(S.new('top', nil).resume!(nil)).to be_nil end # it 'receive_p should raise NoMethodError' do - lambda { Edoors::Iota.new('top', nil).receive_p nil }.should raise_error(NoMethodError) + expect(lambda { Edoors::Iota.new('top', nil).receive_p nil }).to raise_error(NoMethodError) end # end diff --git a/spec/link_spec.rb b/spec/link_spec.rb index 49f086a..cff424b 100644 --- a/spec/link_spec.rb +++ b/spec/link_spec.rb @@ -14,20 +14,20 @@ describe Edoors::Link do p.set_data Edoors::LNK_KEYS, ['f0','f2'] p.set_data Edoors::LNK_VALUE, {'f0'=>'v0','f1'=>'v1','f2'=>'v2'} lnk = Edoors::Link.from_particle p - lnk.src.should eql 'input1' - lnk.dsts.should eql ['concat1?follow','output1'] - lnk.keys.should eql ['f0','f2'] - lnk.value.should == {'f0'=>'v0','f1'=>'v1','f2'=>'v2'} + expect(lnk.src).to eql 'input1' + expect(lnk.dsts).to eql ['concat1?follow','output1'] + expect(lnk.keys).to eql ['f0','f2'] + expect(lnk.value).to be == {'f0'=>'v0','f1'=>'v1','f2'=>'v2'} end # it "link->json->link" do link = Edoors::Link.new 'input1', ['concat1?follow','output1'], ['f0','f2'], {'f0'=>'v0','f1'=>'v1','f2'=>'v2'} lnk = Edoors::Link.json_create( JSON.load( JSON.generate(link) ) ) - link.src.should eql lnk.src - link.dsts.should eql lnk.dsts - link.keys.should eql lnk.keys - link.value.should eql lnk.value - JSON.generate(link).should eql JSON.generate(lnk) + expect(link.src).to eql lnk.src + expect(link.dsts).to eql lnk.dsts + expect(link.keys).to eql lnk.keys + expect(link.value).to eql lnk.value + expect(JSON.generate(link)).to eql JSON.generate(lnk) end # end diff --git a/spec/particle_spec.rb b/spec/particle_spec.rb index 862ad14..58437f3 100644 --- a/spec/particle_spec.rb +++ b/spec/particle_spec.rb @@ -10,14 +10,14 @@ describe Edoors::Particle do p = Edoors::Particle.new # p['key']=666 - p['key'].should eql 666 - p.data('key').should eql 666 - p.get_data('key').should eql 666 + expect(p['key']).to eql 666 + expect(p.data('key')).to eql 666 + expect(p.get_data('key')).to eql 666 # p.set_data 'key', 69 - p['key'].should eql 69 - p.data('key').should eql 69 - p.get_data('key').should eql 69 + expect(p['key']).to eql 69 + expect(p.data('key')).to eql 69 + expect(p.get_data('key')).to eql 69 end # it "payload clone" do @@ -27,14 +27,14 @@ describe Edoors::Particle do o = Edoors::Particle.new o.clone_data p p['k00']=nil - p['k00'].should be_nil - o['k00']['k0'].should eql 0 - o['k00']['k1'].should eql 1 + expect(p['k00']).to be_nil + expect(o['k00']['k0']).to eql 0 + expect(o['k00']['k1']).to eql 1 p['k11']=nil - p['k11'].should be_nil - o['k11'][0].should eql 1 - o['k11'][1].should eql 2 - o['k11'][2].should eql 3 + expect(p['k11']).to be_nil + expect(o['k11'][0]).to eql 1 + expect(o['k11'][1]).to eql 2 + expect(o['k11'][2]).to eql 3 end # it "particle merge" do @@ -44,84 +44,84 @@ describe Edoors::Particle do o = Edoors::Particle.new p.merge! q p.merge! o - p.merged(0).should be q - p.merged(1).should be o - p.merged(2).should be_nil + expect(p.merged(0)).to be q + expect(p.merged(1)).to be o + expect(p.merged(2)).to be_nil c = 0 p.each_merged do |o| - o.should be p.merged(c) + expect(o).to be p.merged(c) c+=1 end - c.should be 2 - p.merged_length.should be 2 - p.merged_shift.should be q - p.merged(0).should be o - p.merged(1).should be_nil + expect(c).to be 2 + expect(p.merged_length).to be 2 + expect(p.merged_shift).to be q + expect(p.merged(0)).to be o + expect(p.merged(1)).to be_nil c = 0 p.each_merged do |o| - o.should be p.merged(c) + expect(o).to be p.merged(c) c+=1 end - c.should be 1 - p.merged_length.should be 1 - p.merged_shift.should be o - p.merged(0).should be_nil + expect(c).to be 1 + expect(p.merged_length).to be 1 + expect(p.merged_shift).to be o + expect(p.merged(0)).to be_nil c = 0 p.each_merged do |o| - o.should be p.merged(c) + expect(o).to be p.merged(c) c+=1 end - c.should be 0 - p.merged_length.should be 0 + expect(c).to be 0 + expect(p.merged_length).to be 0 p.merge! q p.merge! o - p.merged(0).should be q - p.merged(1).should be o + expect(p.merged(0)).to be q + expect(p.merged(1)).to be o p.clear_merged! - p.merged(0).should be_nil + expect(p.merged(0)).to be_nil p.merge! q p.merge! o - p.merged(0).should be q - p.merged(1).should be o + expect(p.merged(0)).to be q + expect(p.merged(1)).to be o p.clear_merged! spin - p.merged(0).should be_nil - spin.require_p(Edoors::Particle).should be o - spin.require_p(Edoors::Particle).should be q + expect(p.merged(0)).to be_nil + expect(spin.require_p(Edoors::Particle)).to be o + expect(spin.require_p(Edoors::Particle)).to be q end # it "routing: add_dsts, next_dst and dst_routed!" do p = Edoors::Particle.new d0 = Edoors::Door.new 'door0', nil d1 = Edoors::Door.new 'door1', nil - p.dst.should be_nil - p.next_dst.should be_nil + expect(p.dst).to be_nil + expect(p.next_dst).to be_nil p.add_dsts 'some?where', 'room0/room1/door?action', 'room/door', 'door' - p.next_dst.should eql 'some?where' + expect(p.next_dst).to eql 'some?where' p.dst_routed! d0 - p.dst.should be d0 - p.next_dst.should eql 'room0/room1/door?action' + expect(p.dst).to be d0 + expect(p.next_dst).to eql 'room0/room1/door?action' p.dst_routed! d1 - p.dst.should be d1 - p.next_dst.should eql 'room/door' + expect(p.dst).to be d1 + expect(p.next_dst).to eql 'room/door' p.dst_routed! nil - p.dst.should be_nil - p.next_dst.should eql 'door' + expect(p.dst).to be_nil + expect(p.next_dst).to eql 'door' end # it "wrong path should raise exeption" do p = Edoors::Particle.new - lambda { p.add_dst 'action', '/room' }.should raise_error(Edoors::Exception) - lambda { p.add_dst 'action', 'room/' }.should raise_error(Edoors::Exception) - lambda { p.add_dst '', 'room/' }.should raise_error(Edoors::Exception) - lambda { p.add_dst 'action', 'room//door' }.should raise_error(Edoors::Exception) - lambda { p.add_dst ' ' }.should raise_error(Edoors::Exception) - lambda { p.add_dst ' ', '' }.should raise_error(Edoors::Exception) - lambda { p.add_dst 'f f' }.should raise_error(Edoors::Exception) - lambda { p.add_dst '', ' d' }.should raise_error(Edoors::Exception) - lambda { p.add_dst '' }.should raise_error(Edoors::Exception) - lambda { p.add_dst '', '' }.should raise_error(Edoors::Exception) - lambda { p.add_dst nil }.should raise_error(TypeError) - lambda { p.add_dst 'action', nil }.should raise_error(NoMethodError) + expect(lambda { p.add_dst 'action', '/room' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst 'action', 'room/' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst '', 'room/' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst 'action', 'room//door' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst ' ' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst ' ', '' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst 'f f' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst '', ' d' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst '' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst '', '' }).to raise_error(Edoors::Exception) + expect(lambda { p.add_dst nil }).to raise_error(TypeError) + expect(lambda { p.add_dst 'action', nil }).to raise_error(NoMethodError) end # it "routing: set_dst!" do @@ -129,14 +129,14 @@ describe Edoors::Particle do d0 = Edoors::Door.new 'door0', nil # p.set_dst! 'action', d0 - p.action.should eql 'action' - p.dst.should be d0 + expect(p.action).to eql 'action' + expect(p.dst).to be d0 # p.set_dst! 'action', '/world/room/door' - p.action.should eql 'action' - p.dst.should be nil - p.room.should eql '/world/room' - p.door.should eql 'door' + expect(p.action).to eql 'action' + expect(p.dst).to be nil + expect(p.room).to eql '/world/room' + expect(p.door).to eql 'door' end # it "routing: add_dst and split_dst!" do @@ -144,51 +144,51 @@ describe Edoors::Particle do d0 = Edoors::Door.new 'door0', nil # p.split_dst! - p.room.should be_nil - p.door.should be_nil - p.action.should be_nil + expect(p.room).to be_nil + expect(p.door).to be_nil + expect(p.action).to 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' + expect(p.room).to eql 'room0/room1' + expect(p.door).to eql 'door' + expect(p.action).to eql 'action' p.clear_dsts! # p.add_dst 'action', 'room/door' p.split_dst! - p.room.should eql 'room' - p.door.should eql 'door' - p.action.should eql 'action' + expect(p.room).to eql 'room' + expect(p.door).to eql 'door' + expect(p.action).to eql 'action' p.clear_dsts! # p.add_dst 'action', '' p.split_dst! - p.room.should be_nil - p.door.should be_nil - p.action.should eql 'action' + expect(p.room).to be_nil + expect(p.door).to be_nil + expect(p.action).to eql 'action' p.clear_dsts! # p.add_dst 'action' p.split_dst! - p.room.should be_nil - p.door.should be_nil - p.action.should eql 'action' + expect(p.room).to be_nil + expect(p.door).to be_nil + expect(p.action).to eql 'action' p.clear_dsts! # p.add_dsts 'door?action', '?action' p.split_dst! - p.room.should be_nil - p.door.should eql 'door' - p.action.should eql 'action' + expect(p.room).to be_nil + expect(p.door).to eql 'door' + expect(p.action).to eql 'action' # p.dst_routed! d0 # - p.dst.should be d0 + expect(p.dst).to be d0 p.split_dst! - p.room.should be_nil - p.door.should be_nil - p.action.should eql 'action' + expect(p.room).to be_nil + expect(p.door).to be_nil + expect(p.action).to eql 'action' # end # @@ -197,11 +197,11 @@ describe Edoors::Particle do d = Edoors::Door.new 'door', nil p.init! d p.add_dsts 'door?action', '?action' - p.next_dst.should eql 'door?action' + expect(p.next_dst).to eql 'door?action' p.error! 'err_msg' - p[Edoors::FIELD_ERROR_MSG].should eql 'err_msg' - p.action.should eq Edoors::ACT_ERROR - p.dst.should be d + expect(p[Edoors::FIELD_ERROR_MSG]).to eql 'err_msg' + expect(p.action).to eq Edoors::ACT_ERROR + expect(p.dst).to be d end # it "link keys and link values" do @@ -211,13 +211,13 @@ describe Edoors::Particle do p['k2'] = 'v2' p['k3'] = 'v3' p.set_link_keys 'k0', 'k2', 'k1' - p.link_value.should == {'k0'=>'v0','k1'=>'v1','k2'=>'v2'} + expect(p.link_value).to be == {'k0'=>'v0','k1'=>'v1','k2'=>'v2'} p.del_data 'k0' - p.link_value.should == {'k1'=>'v1','k2'=>'v2'} + expect(p.link_value).to be == {'k1'=>'v1','k2'=>'v2'} p.set_link_keys 'k1', 'k0' - p.link_value.should == {'k1'=>'v1'} + expect(p.link_value).to be == {'k1'=>'v1'} p['k1']='vX' - p.link_value.should == {'k1'=>'vX'} + expect(p.link_value).to be == {'k1'=>'vX'} end # it 'link_with?' do @@ -225,9 +225,9 @@ describe Edoors::Particle do p['k0'] = 'v0' p['k1'] = 'v1' p['k2'] = 'v2' - p.link_with?(Edoors::Link.new('', '', '')).should be_true - p.link_with?(Edoors::Link.new('', '', '', {'k0'=>'v0','k1'=>'v1'})).should be_true - p.link_with?(Edoors::Link.new('', '', '', {'k0'=>'v2','k1'=>'v1'})).should be_false + expect(p.link_with?(Edoors::Link.new('', '', ''))).to be_truthy + expect(p.link_with?(Edoors::Link.new('', '', '', {'k0'=>'v0','k1'=>'v1'}))).to be_truthy + expect(p.link_with?(Edoors::Link.new('', '', '', {'k0'=>'v2','k1'=>'v1'}))).to be_falsy end # it "apply_link!" do @@ -237,16 +237,16 @@ describe Edoors::Particle do p['k2'] = 'v2' p.set_link_keys 'k0', 'k2' p.add_dsts 'door?action', '?action' - p.src.should be_nil - p.link_value.should == {'k0'=>'v0','k2'=>'v2'} - p.next_dst.should eql 'door?action' + expect(p.src).to be_nil + expect(p.link_value).to be == {'k0'=>'v0','k2'=>'v2'} + expect(p.next_dst).to eql 'door?action' lnk = Edoors::Link.new('door0', ['door1?get','door2'], 'k1', {'f0'=>'v0','f1'=>'v1'}) f = Fake.new 'fake', nil lnk.door = f p.apply_link! lnk - p.src.should be f - p.next_dst.should eql 'door1?get' - p.link_value.should == {'k1'=>'v1'} + expect(p.src).to be f + expect(p.next_dst).to eql 'door1?get' + expect(p.link_value).to be == {'k1'=>'v1'} end # it "particle->json->particle" do @@ -275,30 +275,30 @@ describe Edoors::Particle do o = JSON.load( JSON.generate(p0) ) o['spin'] = s0 px = Edoors::Particle.json_create( o ) - ((px.ts-p0.ts)<0.5).should be_true - px.src.should be s3 - px.dst.should be_nil - px.room.should eql 'room0/room1/room2' - px.door.should eql 'doorX' - px.action.should eql 'myaction' - px.next_dst.should eql 'room0/room1/room2/doorX?myaction' - px.link_value.should == {'k0'=>'v0','k2'=>'v2'} - px['k0'].should eql 'v0' - px['k1'].should eql 'v1' - px['k2'].should eql 'v2' + expect(((px.ts-p0.ts)<0.5)).to be_truthy + expect(px.src).to be s3 + expect(px.dst).to be_nil + expect(px.room).to eql 'room0/room1/room2' + expect(px.door).to eql 'doorX' + expect(px.action).to eql 'myaction' + expect(px.next_dst).to eql 'room0/room1/room2/doorX?myaction' + expect(px.link_value).to be == {'k0'=>'v0','k2'=>'v2'} + expect(px['k0']).to eql 'v0' + expect(px['k1']).to eql 'v1' + expect(px['k2']).to eql 'v2' py = px.merged(0) - ((py.ts-p1.ts)<0.5).should be_true - py.src.should be s3 - py.dst.should be s4 - py.room.should be_nil - py.door.should be_nil - py.action.should be_nil - py.next_dst.should eql 'room0/room1/door?action' - py.link_value.should == {'k3'=>'v6','k4'=>'v7','k5'=>'v8'} - py['k3'].should eql 'v6' - py['k4'].should eql 'v7' - py['k5'].should eql 'v8' - JSON.generate(p0).should eql JSON.generate(px) + expect(((py.ts-p1.ts)<0.5)).to be_truthy + expect(py.src).to be s3 + expect(py.dst).to be s4 + expect(py.room).to be_nil + expect(py.door).to be_nil + expect(py.action).to be_nil + expect(py.next_dst).to eql 'room0/room1/door?action' + expect(py.link_value).to be == {'k3'=>'v6','k4'=>'v7','k5'=>'v8'} + expect(py['k3']).to eql 'v6' + expect(py['k4']).to eql 'v7' + expect(py['k5']).to eql 'v8' + expect(JSON.generate(p0)).to eql JSON.generate(px) end # end diff --git a/spec/room_spec.rb b/spec/room_spec.rb index c0b361e..34c6800 100644 --- a/spec/room_spec.rb +++ b/spec/room_spec.rb @@ -17,23 +17,23 @@ describe Edoors::Room do it "add_iota and add_link correctly" do r0 = Edoors::Room.new 'room0', @spin d0 = Edoors::Door.new 'door0', r0 - lambda { Edoors::Door.new('door0', r0) }.should raise_error(Edoors::Exception) - lambda { r0.add_iota Edoors::Door.new('door1', r0) }.should raise_error(Edoors::Exception) + expect(lambda { Edoors::Door.new('door0', r0) }).to raise_error(Edoors::Exception) + expect(lambda { r0.add_iota Edoors::Door.new('door1', r0) }).to raise_error(Edoors::Exception) r0.add_link Edoors::Link.new 'door0', 'somewhere' - lambda { r0.add_link(Edoors::Link.new('nowhere', 'somewhere')) }.should raise_error(Edoors::Exception) + expect(lambda { r0.add_link(Edoors::Link.new('nowhere', 'somewhere')) }).to raise_error(Edoors::Exception) end # it "start! and stop! should work" do r0 = Edoors::Room.new 'room0', @spin d0 = Fake.new 'fake', r0 - d0.start.should be_nil - d0.stop.should be_nil + expect(d0.start).to be_nil + expect(d0.stop).to be_nil r0.start! - d0.start.should be_true - d0.stop.should be_nil + expect(d0.start).to be_truthy + expect(d0.stop).to be_nil r0.stop! - d0.start.should be_true - d0.stop.should be_true + expect(d0.start).to be_truthy + expect(d0.stop).to be_truthy end # it "parent, spin and search_down should be ok" do @@ -42,20 +42,20 @@ describe Edoors::Room do r2 = Edoors::Room.new 'r2', r1 r3 = Edoors::Room.new 'r3', @spin r4 = Edoors::Room.new 'r4', r3 - r2.parent.should be r1 - r1.parent.should be r0 - r0.parent.should be @spin - r0.spin.should be @spin - r1.spin.should be @spin - r2.spin.should be @spin - r3.spin.should be @spin - @spin.search_down('dom0/r0/r1/r2').should be r2 - r0.search_down('dom0/r0/r1/r2').should be r2 - r1.search_down('dom0/r0/r1/r2').should be r2 - r2.search_down('dom0/r0/r1/r2').should be r2 - r1.search_down('dom0/r0/r1/r9').should be nil - r3.search_down('dom0/r0/r1/r2').should be nil - r4.search_down('dom0/r0/r1/r2').should be nil + expect(r2.parent).to be r1 + expect(r1.parent).to be r0 + expect(r0.parent).to be @spin + expect(r0.spin).to be @spin + expect(r1.spin).to be @spin + expect(r2.spin).to be @spin + expect(r3.spin).to be @spin + expect(@spin.search_down('dom0/r0/r1/r2')).to be r2 + expect(r0.search_down('dom0/r0/r1/r2')).to be r2 + expect(r1.search_down('dom0/r0/r1/r2')).to be r2 + expect(r2.search_down('dom0/r0/r1/r2')).to be r2 + expect(r1.search_down('dom0/r0/r1/r9')).to be nil + expect(r3.search_down('dom0/r0/r1/r2')).to be nil + expect(r4.search_down('dom0/r0/r1/r2')).to be nil end # it "routing success (direct add_dst)" do @@ -65,8 +65,8 @@ describe Edoors::Room do p.init! Fake.new( 'fake', @spin) p.add_dst 'get', 'door0' room0.send_p p - p.action.should eql 'get' - p.dst.should be door0 + expect(p.action).to eql 'get' + expect(p.dst).to be door0 end # it "routing success (direct send to self)" do @@ -75,8 +75,8 @@ describe Edoors::Room do p = @spin.require_p Edoors::Particle p.init! Fake.new( 'fake', @spin) door0.send_p p, 'get' - p.action.should eql 'get' - p.dst.should be door0 + expect(p.action).to eql 'get' + expect(p.dst).to be door0 end # it "routing success (direct send to pointer)" do @@ -85,8 +85,8 @@ describe Edoors::Room do p = @spin.require_p Edoors::Particle p.init! Fake.new( 'fake', @spin) door0.send_p p, 'get', door0 - p.action.should eql 'get' - p.dst.should be door0 + expect(p.action).to eql 'get' + expect(p.dst).to be door0 end # it "routing success (direct send to path)" do @@ -95,8 +95,8 @@ describe Edoors::Room do p = @spin.require_p Edoors::Particle p.init! Fake.new( 'fake', @spin) door0.send_p p, 'get', door0.path - p.action.should eql 'get' - p.dst.should be door0 + expect(p.action).to eql 'get' + expect(p.dst).to be door0 end # it "routing success through Spin@world" do @@ -107,8 +107,8 @@ describe Edoors::Room do p.init! Fake.new('fake', @spin) p.add_dst 'get', 'dom0/room0/room1/door0' room0.send_p p - p.action.should eql 'get' - p.dst.should be door0 + expect(p.action).to eql 'get' + expect(p.dst).to be door0 end # it "route error: no source" do @@ -116,9 +116,9 @@ describe Edoors::Room do p = @spin.require_p Edoors::Particle p.add_dst 'get', 'room/door' room.send_p p - p.action.should eql Edoors::ACT_ERROR - p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_NS - p.dst.should be room.spin + expect(p.action).to eql Edoors::ACT_ERROR + expect(p[Edoors::FIELD_ERROR_MSG]).to eql Edoors::ERROR_ROUTE_NS + expect(p.dst).to be room.spin end # it "route error: no destination no links" do @@ -126,9 +126,9 @@ describe Edoors::Room do p = @spin.require_p Edoors::Particle p.init! Fake.new('fake', @spin) room.send_p p - p.action.should eql Edoors::ACT_ERROR - p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_NDNL - p.dst.should be p.src + expect(p.action).to eql Edoors::ACT_ERROR + expect(p[Edoors::FIELD_ERROR_MSG]).to eql Edoors::ERROR_ROUTE_NDNL + expect(p.dst).to be p.src end # it "route error: no rooom, wrong door -> right room wrong door" do @@ -137,9 +137,9 @@ describe Edoors::Room do p.init! Fake.new('fake', @spin) p.add_dst 'get', 'nodoor' room0.send_p p - p.action.should eql Edoors::ACT_ERROR - p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_RRWD - p.dst.should be p.src + expect(p.action).to eql Edoors::ACT_ERROR + expect(p[Edoors::FIELD_ERROR_MSG]).to eql Edoors::ERROR_ROUTE_RRWD + expect(p.dst).to be p.src end # it "route error: right rooom, wrong door -> right room wrong door" do @@ -148,9 +148,9 @@ describe Edoors::Room do p.init! Fake.new('fake', @spin) p.add_dst 'get', 'dom0/room0/nodoor' room0.send_p p - p.action.should eql Edoors::ACT_ERROR - p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_RRWD - p.dst.should be p.src + expect(p.action).to eql Edoors::ACT_ERROR + expect(p[Edoors::FIELD_ERROR_MSG]).to eql Edoors::ERROR_ROUTE_RRWD + expect(p.dst).to be p.src end # it "route error: right room, wrong door through Spin@world -> does not exists" do @@ -160,9 +160,9 @@ describe Edoors::Room do p.init! Fake.new('fake', room0) p.add_dst 'get', 'dom0/room0/nodoor' room1.send_p p - p.action.should eql Edoors::ACT_ERROR - p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_DNE - p.dst.should be p.src + expect(p.action).to eql Edoors::ACT_ERROR + expect(p[Edoors::FIELD_ERROR_MSG]).to eql Edoors::ERROR_ROUTE_DNE + expect(p.dst).to be p.src end # it "route error: wrong room, right door through Spin@world -> does not exists" do @@ -172,9 +172,9 @@ describe Edoors::Room do p.init! Fake.new('fake', @spin) p.add_dst 'get', 'dom0/noroom/fake' room1.send_p p - p.action.should eql Edoors::ACT_ERROR - p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_DNE - p.dst.should be p.src + expect(p.action).to eql Edoors::ACT_ERROR + expect(p[Edoors::FIELD_ERROR_MSG]).to eql Edoors::ERROR_ROUTE_DNE + expect(p.dst).to be p.src end # it "routing ~failure: no door name -> src" do @@ -184,8 +184,8 @@ describe Edoors::Room do p.init! door0 p.add_dst 'get' room0.send_p p - p.action.should eql 'get' - p.dst.should be door0 + expect(p.action).to eql 'get' + expect(p.dst).to be door0 end # it "routing success: unconditional link" do @@ -195,8 +195,8 @@ describe Edoors::Room do room0.add_link Edoors::Link.new('door0', 'door1') p = @spin.require_p Edoors::Particle door0.send_p p - p.action.should be_nil - p.dst.should be door1 + expect(p.action).to be_nil + expect(p.dst).to be door1 end # it "routing success: conditional link" do @@ -208,9 +208,9 @@ describe Edoors::Room do p['f0']='v0' p['f1']='v1' door0.send_p p - p.action.should be_nil - p.src.should be door0 - p.dst.should be door1 + expect(p.action).to be_nil + expect(p.src).to be door0 + expect(p.dst).to be door1 end # it "routing success: more then one matching link" do @@ -219,8 +219,8 @@ describe Edoors::Room do class Out < Edoors::Door attr_reader :count def receive_p p - @count||=0 - ['0','1','2'][@count].should == p.next_dst + @count ||= 0 + expect(['0','1','2'][@count]).to be == p.next_dst @count += 1 end end @@ -235,15 +235,15 @@ describe Edoors::Room do p['f1']='v1' door0.send_p p @spin.spin! - door1.count.should eql 3 + expect(door1.count).to eql 3 end # it "system route error: system no destination" do room0 = Edoors::Room.new 'room0', @spin p = @spin.require_p Edoors::Particle room0.send_sys_p p - p.action.should eql Edoors::ACT_ERROR - p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_SND + expect(p.action).to eql Edoors::ACT_ERROR + expect(p[Edoors::FIELD_ERROR_MSG]).to eql Edoors::ERROR_ROUTE_SND end # it "system routing success: action only" do @@ -251,8 +251,8 @@ describe Edoors::Room do p = @spin.require_p Edoors::Particle p.add_dst Edoors::SYS_ACT_ADD_LINK room0.send_sys_p p - p.action.should eql Edoors::SYS_ACT_ADD_LINK - p.dst.should be room0.spin + expect(p.action).to eql Edoors::SYS_ACT_ADD_LINK + expect(p.dst).to be room0.spin end # it "system routing success (add_dst)" do @@ -261,8 +261,8 @@ describe Edoors::Room do p = @spin.require_p Edoors::Particle p.add_dst Edoors::SYS_ACT_ADD_LINK, 'dom0/room0/door0' room0.send_sys_p p - p.action.should eql Edoors::SYS_ACT_ADD_LINK - p.dst.should be door0 + expect(p.action).to eql Edoors::SYS_ACT_ADD_LINK + expect(p.dst).to be door0 end # it "system routing success (send_sys_p)" do @@ -270,8 +270,8 @@ describe Edoors::Room do door0 = Edoors::Door.new 'door0', room0 p = @spin.require_p Edoors::Particle door0.send_sys_p p, Edoors::SYS_ACT_ADD_LINK - p.action.should eql Edoors::SYS_ACT_ADD_LINK - p.dst.should be door0 + expect(p.action).to eql Edoors::SYS_ACT_ADD_LINK + expect(p.dst).to be door0 end # it "SYS_ACT_ADD_LINK" do @@ -290,9 +290,9 @@ describe Edoors::Room do p['f0']='v0' p['f1']='v1' door0.send_p p - p.action.should be_nil - p.src.should be door0 - p.dst.should be door1 + expect(p.action).to be_nil + expect(p.src).to be door0 + expect(p.dst).to be door1 end # it "SYS_ACT_ADD_ROOM" do @@ -306,9 +306,9 @@ describe Edoors::Room do p1.set_dst! Edoors::SYS_ACT_ADD_ROOM, room0 @spin.send_sys_p p1 @spin.spin! - @spin.search_world('dom0/room0/roomX').should be_a Edoors::Room - @spin.search_world('dom0/room0/roomY').should be_a Edoors::Room - @spin.search_world('dom0/room0/roomZ').should be nil + expect(@spin.search_world('dom0/room0/roomX')).to be_a Edoors::Room + expect(@spin.search_world('dom0/room0/roomY')).to be_a Edoors::Room + expect(@spin.search_world('dom0/room0/roomZ')).to be nil end # it "room->json->room" do @@ -325,7 +325,7 @@ describe Edoors::Room do r1.add_link Edoors::Link.new('d1', 'd0') r2.add_link Edoors::Link.new('d2', 'd1', 'fies', {'f5'=>'v9','f1'=>'v1'}) rx = Edoors::Room.json_create( JSON.load( JSON.generate(r0) ) ) - JSON.generate(r0).should eql JSON.generate(rx) + expect(JSON.generate(r0)).to eql JSON.generate(rx) end# # end diff --git a/spec/spin_spec.rb b/spec/spin_spec.rb index 78f7f87..9142549 100644 --- a/spec/spin_spec.rb +++ b/spec/spin_spec.rb @@ -12,37 +12,37 @@ describe Edoors::Spin do spin = Edoors::Spin.new 'dom0' p0 = spin.require_p Edoors::Particle p1 = spin.require_p Edoors::Particle - (p0===p1).should be_false + expect(p0===p1).to be_falsey spin.release_p p0 p2 = spin.require_p Edoors::Particle - (p0===p2).should be_true + expect(p0===p2).to be_truthy end # it "different Particles classes in pool" do spin = Edoors::Spin.new 'dom0' p0 = spin.require_p Edoors::Particle p1 = spin.require_p Edoors::Particle - (p0===p1).should be_false + expect(p0===p1).to be_falsey spin.release_p p0 p2 = spin.require_p MyP p3 = spin.require_p MyP - (p2===p3).should be_false + expect(p2===p3).to be_falsey spin.release_p p2 p4 = spin.require_p MyP - (p2===p4).should be_true + expect(p2===p4).to be_truthy end # it "release of merged particles" do spin = Edoors::Spin.new 'dom0' p0 = spin.require_p Edoors::Particle p1 = spin.require_p Edoors::Particle - (p0===p1).should be_false + expect(p0===p1).to be_falsey p0.merge! p1 spin.release_p p0 p2 = spin.require_p Edoors::Particle - (p2===p0).should be_true + expect(p2===p0).to be_truthy p3 = spin.require_p Edoors::Particle - (p3===p1).should be_true + expect(p3===p1).to be_truthy end # it "clear!" do @@ -53,8 +53,8 @@ describe Edoors::Spin do spin.release_p p1 spin.clear! p2 = spin.require_p Edoors::Particle - (p2==p0).should be_false - (p2==p1).should be_false + expect(p2==p0).to be_falsey + expect(p2==p1).to be_falsey end # it "post_p post_sys_p spin!" do @@ -68,8 +68,8 @@ describe Edoors::Spin do spin.post_sys_p p1 spin.run = true spin.spin! - f.p.should be p0 - f.sp.should be p1 + expect(f.p).to be p0 + expect(f.sp).to be p1 spin.stop_spinning! end # @@ -80,16 +80,16 @@ describe Edoors::Spin do spin.send_sys_p p0 spin.spin! p1 = spin.require_p Edoors::Particle - p0.should be p0 + expect(p0).to be p0 end # it "option debug" do spin = Edoors::Spin.new 'dom0' - spin.debug_routing.should be false - spin.debug_garbage.should be false + expect(spin.debug_routing).to be false + expect(spin.debug_garbage).to be false spin = Edoors::Spin.new 'dom0', :debug_routing=>true, :debug_garbage=>true - spin.debug_routing.should be true - spin.debug_garbage.should be true + expect(spin.debug_routing).to be true + expect(spin.debug_garbage).to be true end # it "search world" do @@ -97,9 +97,9 @@ describe Edoors::Spin do r0 = Edoors::Room.new 'r0', spin r1 = Edoors::Room.new 'r1', r0 r2 = Edoors::Room.new 'r2', r1 - spin.search_world(r0.path).should be r0 - spin.search_world(r1.path).should be r1 - spin.search_world(r2.path).should be r2 + expect(spin.search_world(r0.path)).to be r0 + expect(spin.search_world(r1.path)).to be r1 + expect(spin.search_world(r2.path)).to be r2 end # it "spin->json->spin" do @@ -120,7 +120,7 @@ describe Edoors::Spin do spin.post_sys_p p2 json = JSON.generate spin dom0 = Edoors::Spin.json_create( JSON.load( json ) ) - json.should eql JSON.generate(dom0) + expect(json).to eql JSON.generate(dom0) end # it "hibernate! resume!" do @@ -133,7 +133,7 @@ describe Edoors::Spin do spin.send_sys_p p0 spin.spin! dom0 = Edoors::Spin.resume! spin.hibernate_path - dom0.name.should eql spin.name + expect(dom0.name).to eql spin.name File.unlink dom0.hibernate_path end # |