spec/task_spec.rb in screwcap-0.6.3 vs spec/task_spec.rb in screwcap-0.7

- old
+ new

@@ -25,10 +25,11 @@ run "test" unknown_action end commands = task.__build_commands([unknown]) + task.__built_commands.should_not == [] commands.size.should == 2 commands[0][:type].should == :remote commands[0][:from].should == :test commands[0][:command].should == "test" @@ -131,25 +132,10 @@ commands = task2.__build_commands([after2]) commands.map {|c| c[:command] }.should == ["deploy", "after"] end - it "should validate" do - task = Task.new :name => :test - lambda { task.validate([]) }.should raise_error(Screwcap::ConfigurationError) - - server = Server.new :name => :server, :address => "none", :user => "yeah" - other_server = Server.new :name => :server2, :address => "none", :user => "yeah" - task = Task.new :name => :test, :server => :server - lambda { task.validate([server]) }.should_not raise_error - lambda { task.validate([other_server]) }.should raise_error(Screwcap::ConfigurationError) - task = Task.new :name => :test, :servers => :server - lambda { task.validate([server]) }.should_not raise_error - task = Task.new :name => :test, :servers => [:server, :server2] - lambda { task.validate([server,other_server]) }.should_not raise_error - end - it "should handle before and after inside a task" do do_other_task = Task.new :name => :other_task do run "task" end task = Task.new :name => :task do @@ -279,14 +265,32 @@ commands = task.__build_commands [n1, n2, n3] commands.map {|c| c[:command] }.should == %w(unlock_the_gate release_the_hounds lock_the_gate) end it "has an ex command" do - task = Task.new :name => :task do @test = "asdf" ex { @test = "fdsa" } end commands = task.__build_commands([task]) + commands[0][:type].should == :block + end + + it "should be able to call other tasks" do + t1 = Task.new :name => :release_the_hounds do + run "release_the_hounds" + end + + t2 = Task.new :name => :lock_the_gate do + run "lock_the_gate" + end + + t3 = Task.new :name => :release_the_hounds_and_lock_the_gate do + release_the_hounds + lock_the_gate + end + + commands = t3.__build_commands [t1, t2] + commands.map {|c| c[:command] }.should == %w(release_the_hounds lock_the_gate) end end