Sha256: b043a0a50751b1af50f0c60df70f4feea1f6f7e0885007b34c033d646527104e

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require "spec_helper"

describe DynoScaler::Heroku do
  let(:application) { 'my-application-on-heroku' }
  let(:options) { nil }
  subject(:heroku_client) { DynoScaler::Heroku.new application, options }

  describe "scaling workers" do
    let(:heroku_api) { mock(::Heroku::API, :post_ps_scale => false) }

    before do
      ::Heroku::API.stub!(:new).and_return(heroku_api)
    end

    let(:quantity) { 2 }

    it "scales workers of the application to the given number of workers" do
      heroku_api.should_receive(:post_ps_scale).with(application, 'worker', quantity)
      heroku_client.scale_workers(quantity)
    end
  end

  describe "getting number of running workers" do
    let(:options) { { mock: true } } # Mock Excon http requests

    before { Excon.stub({method: :get}, {body: body, status: 200}) }

    context "when there are running workers" do
      let(:body) do
        [{"process"=>"web.1"}, {"process"=>"worker.1"}, {"process"=>"worker.2"}]
      end

      its(:running_workers) { should eq(2) }
    end

    context "when there are no running workers" do
      let(:body) { [{"process"=>"web.1"}] }

      its(:running_workers) { should be_zero }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dyno_scaler-0.2.0 spec/dyno_scaler/heroku_spec.rb