Sha256: d9eaf39bebc4c101f8758657d2b1dd4fe6bc29175c5f028efde54536f74114d6

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require "spec_helper"

describe SiblingDeployer do
  before do
    @sibling_deploy = mock(Sibling::Deploy)
    Sibling::Deploy.stub(:find) { @sibling_deploy }
  end

  describe ".perform" do
    it "deploys entry feed" do
      @sibling_deploy.should_receive(:deploy).once
      SiblingDeployer.perform(1)
    end

    it "does not swallow errors" do
      @sibling_deploy.stub(:deploy).and_raise(StandardError.new("Foo"))
      lambda { SiblingDeployer.perform(1) }.should raise_error(StandardError, "Foo")
    end
  end

  describe "when an exception is raised" do
    before do
     @sibling_deployer = SiblingDeployer.new(1)
    end

    it "retries 0 times when Exception" do
      @sibling_deploy.stub(:deploy).and_raise(Exception)
      expect { @sibling_deployer.perform }.to raise_error(Exception)
      expect(@sibling_deployer.retries).to eq 0
    end

    it "retries 3 times when GithubHerokuDeployer::CommandException" do
      @sibling_deploy.stub(:deploy).and_raise(GithubHerokuDeployer::CommandException)
      expect { @sibling_deployer.perform }.to raise_error(GithubHerokuDeployer::CommandException)
      expect(@sibling_deployer.retries).to eq 3
    end

    it "retries 3 times when Heroku::API::Errors::ErrorWithResponse" do
      pending "Not sure how to raise this error"
      @sibling_deploy.stub(:deploy).and_raise(Heroku::API::Errors::ErrorWithResponse.new(nil, ))
      expect { @sibling_deployer.perform }.to raise_error(Heroku::API::Errors::ErrorWithResponse)
      expect(@sibling_deployer.retries).to eq 3
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
g5_sibling_deployer_engine-0.2.6 spec/workers/sibling_deployer_spec.rb