spec/trema/dsl/runner_spec.rb in trema-0.1.3.2 vs spec/trema/dsl/runner_spec.rb in trema-0.2.0
- old
+ new
@@ -18,10 +18,11 @@
#
require File.join( File.dirname( __FILE__ ), "..", "..", "spec_helper" )
require "trema/dsl/runner"
+require "trema/ordered-hash"
module Trema
module DSL
describe Runner do
@@ -126,17 +127,29 @@
host0 = mock( "host0" )
host1 = mock( "host1" )
host2 = mock( "host2" )
host0.should_receive( :run! ).once.ordered
- host0.should_receive( :add_arp_entry ).with( [ host1, host2 ] ).once.ordered
+ host0.should_receive( :add_arp_entry ).with do | arg |
+ arg.size.should == 2
+ arg.should include( host1 )
+ arg.should include( host2 )
+ end
host1.should_receive( :run! ).once.ordered
- host1.should_receive( :add_arp_entry ).with( [ host0, host2 ] ).once.ordered
+ host1.should_receive( :add_arp_entry ).with do | arg |
+ arg.size.should == 2
+ arg.should include( host0 )
+ arg.should include( host2 )
+ end
host2.should_receive( :run! ).once.ordered
- host2.should_receive( :add_arp_entry ).with( [ host0, host1 ] ).once.ordered
+ host2.should_receive( :add_arp_entry ).with do | arg |
+ arg.size.should == 2
+ arg.should include( host0 )
+ arg.should include( host1 )
+ end
context = mock(
"context",
:tremashark => nil,
:switch_manager => mock( "switch manager", :run! => nil ),
@@ -177,52 +190,62 @@
Runner.new( context ).run
end
it "should run apps" do
- app0 = mock( "app0" )
+ apps = OrderedHash.new
+
+ app0 = mock( "app0", :name => "app0" )
app0.should_receive( :daemonize! ).once.ordered
+ apps[ "app0" ] = app0
- app1 = mock( "app1" )
+ app1 = mock( "app1", :name => "app1" )
app1.should_receive( :daemonize! ).once.ordered
+ apps[ "app1" ] = app1
- app2 = mock( "app2", :name => "App2" )
+ app2 = mock( "app2", :name => "app2" )
app2.should_receive( :run! ).once.ordered
+ apps[ "app2" ] = app2
context = mock(
"context",
:tremashark => nil,
:switch_manager => mock( "switch manager", :run! => nil, :rule => {} ),
:packetin_filter => nil,
:links => {},
:hosts => {},
:switches => {},
- :apps => { "app0" => app0, "app1" => app1, "app2" => app2 }
+ :apps => apps
)
Runner.new( context ).run
end
it "should daemonize apps" do
+ apps = OrderedHash.new
+
app0 = mock( "app0" )
app0.should_receive( :daemonize! ).once.ordered
+ apps[ "app0" ] = app0
app1 = mock( "app1" )
app1.should_receive( :daemonize! ).once.ordered
+ apps[ "app1" ] = app1
app2 = mock( "app2", :name => "App2" )
app2.should_receive( :daemonize! ).once.ordered
+ apps[ "app2" ] = app2
context = mock(
"context",
:tremashark => nil,
:switch_manager => mock( "switch manager", :run! => nil, :rule => {} ),
:packetin_filter => nil,
:links => {},
:hosts => {},
:switches => {},
- :apps => { "app0" => app0, "app1" => app1, "app2" => app2 }
+ :apps => apps
)
Runner.new( context ).daemonize
end
end