Sha256: 249f4130b314209452d065cab3bfcc4027e68a805a4141239be72d2638f5b44c

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require "spec_helper"

describe Shuttle::Task do
  let(:config) { double(tasks: tasks) }
  let(:deploy) { double(config: config) }
  let(:task)   { described_class.new(deploy, "foo") }

  before do
    allow(task).to receive(:execute)
  end

  describe "#run" do
    context "when task does not exist" do
      let(:tasks) { Hashr.new }

      before do
        allow(deploy).to receive(:error) { raise Shuttle::DeployError }
      end

      it "triggers deployment error" do
        expect { task.run }.to raise_error Shuttle::DeployError
      end
    end

    context "when task does not have commands" do
      let(:tasks) { Hashr.new(foo: []) }

      before do
        task.run
      end

      it "does not execute any commands" do
        expect(task).to have_received(:execute).exactly(0).times
      end
    end

    context "when task has commands" do
      let(:tasks) { Hashr.new(foo: ["cmd1", "cmd2"]) }

      before do
        task.run
      end

      it "executes all commands" do
        expect(task).to have_received(:execute).with("foo", "cmd1", false)
        expect(task).to have_received(:execute).with("foo", "cmd2", false)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shuttle-deploy-0.3.0.beta1 spec/task_spec.rb