Sha256: 17785358b5125a361353d1f7234c02d30d5663e2d42a1a64816ca6e0b005dcef

Contents?: true

Size: 1.81 KB

Versions: 8

Compression:

Stored size: 1.81 KB

Contents

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() }
  end

  it "creates a partial" do
    partial("hello_partial") { hello() }
    expect($partials["hello_partial"][:block]).to be_kind_of(Proc)
  end

  it "executes a partial" do
    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 "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].last).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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
deplomat-0.2.12 spec/directives_spec.rb
deplomat-0.2.11 spec/directives_spec.rb
deplomat-0.2.10 spec/directives_spec.rb
deplomat-0.2.9 spec/directives_spec.rb
deplomat-0.2.8 spec/directives_spec.rb
deplomat-0.2.7 spec/directives_spec.rb
deplomat-0.2.6 spec/directives_spec.rb
deplomat-0.2.5 spec/directives_spec.rb