Sha256: ee784a33c7d97aead8e231edc0024f0675f48fc0163ba60c38570576d11cf66b

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'
require 'paratrooper/pending_migration_check'

describe Paratrooper::PendingMigrationCheck do
  let(:migration_check) do
    described_class.new(match_tag_name, heroku_wrapper, system_caller)
  end
  let(:system_caller) { double(:system_caller) }
  let(:heroku_wrapper) do
    double(:heroku_wrapper, last_deploy_commit: last_deployed_commit)
  end
  let(:last_deployed_commit) { nil }

  describe "#migrations_waiting?" do
    let(:match_tag_name) { "MATCH" }
    let(:last_deployed_commit) { "LAST_DEPLOYED_COMMIT" }

    it "calls out to heroku for latest deploy's commit" do
      system_caller.stub(:execute).and_return("")
      heroku_wrapper.should_receive(:last_deploy_commit)
      migration_check.migrations_waiting?
    end

    context "and migrations are in diff" do
      it "returns true" do
        expected_call = %Q[git diff --shortstat LAST_DEPLOYED_COMMIT MATCH -- db/migrate]
        system_caller.should_receive(:execute).with(expected_call)
          .and_return("DIFF")
        expect(migration_check.migrations_waiting?).to be_true
      end
    end

    context "and migrations are not in diff" do
      let(:match_tag_name) { 'master' }
      let(:last_deployed_commit) { "LAST_DEPLOYED_COMMIT" }

      it "returns false" do
        expected_call = %Q[git diff --shortstat LAST_DEPLOYED_COMMIT master -- db/migrate]
        system_caller.should_receive(:execute).with(expected_call)
          .and_return("")
        expect(migration_check.migrations_waiting?).to be_false
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
paratrooper-2.3.0 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-2.2.0 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-2.1.0 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-2.0.0 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-2.0.0.beta2 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-2.0.0.beta1 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-1.4.2 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-1.4.1 spec/paratrooper/pending_migration_check_spec.rb
paratrooper-1.4.0 spec/paratrooper/pending_migration_check_spec.rb