spec/directives_spec.rb in deplomat-0.1.13 vs spec/directives_spec.rb in deplomat-0.2.0

- old
+ new

@@ -1,9 +1,13 @@ require 'spec_helper' describe "directives" do + before(:each) do + $deplomat_tasks = [] + end + it "executes arbitrary ruby code in a particular environment" do $env = 'staging' expect(self).to receive(:hello).exactly(1).times execute_in(env: 'staging') { hello() } execute_in(env: 'production') { hello() } @@ -18,8 +22,43 @@ expect(self).to receive(:hello).with("hello").exactly(1).times partial("hello_partial") { |args| hello(args[:x]) } execute_partial "hello_partial", x: 'hello' end - it "passes before and after messages" + it "executes tasks consecutively, running before and after callbacks" do + + $out = "" + def task1; $out += "task1"; end + def task2; $out += "task2"; end + def task3; $out += ",task3"; end + + before_task(:task1, 1) { $out += "before_task1:" } + after_task(:task1, 2) { $out += ":after_task1," } + before_task(:task2, 3) { $out += "before_task2:" } + after_task(:task2, 4) { $out += ":after_task2" } + before_task(:task4, 5) { $out += "before_task4:" } + after_task(:task4, 6) { $out += ":after_task4" } + + add_task :task1, :task2, :task3 + + execute_tasks! + expect($out).to eq("before_task1:task1:after_task1,before_task2:task2:after_task2,task3") + + end + + it "loads and runs requisites" do + + def task1;end + def task2;end + + add_task :task1, :task2 + + result = load_requisites!(1, requisites_path: "#{File.expand_path(File.dirname(__FILE__))}/deployment_requisites") + expect(result[:counter]).to eq(2) + expect(result[:log]).to eq(["Loading requisite: 2_req.rb"]) + execute_tasks! + expect($deployment_requisites_test_file1).to be_nil + expect($deployment_requisites_test_file2).to be_truthy + + end end