Sha256: 42fffbbbfd9a737f216d67c8e981a9e236e2f4c43d857ba655eeb9791663a3dd

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe "sync" do
  before { subject.load 'deploy' }

  include_context :capistrano

  context 'db task' do
    let(:application) { "app" }
    let(:host) { "host" }
    let(:port) { "port" }
    let(:username) { "username" }
    let(:namespace) { subject.namespaces[:sync].namespaces[:db] }
    let(:database) { "o2h-db" }
    let(:remote_database) { {"database" => database, "host" => host, "port" => port, "username" => username} }
    let(:local_database) { {"database" => "local-db", "port" => "local-port", "username" => "local-username"} }

    before do
      subject.set(:application) { application }
      subject.set(:shared_path) { "/shared/#{application}" }
      namespace.stub(:remote_database_config) { remote_database }
      namespace.stub(:database_config) { local_database }
    end

    it "should set proper repository" do
      subject.should_receive(:download)
      subject.should_receive(:run_locally).with("gunzip tmp/app-dump.sql.gz | psql -p local-port local-db")
      subject.execute_task(task)
      subject.should have_run("pg_dump -c -Z 9 -p #{port} -h #{host} -U #{username} -f /shared/app/backup/app-dump.sql.gz #{database}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
o2h-0.1.2 spec/recipes/sync_spec.rb
o2h-0.1.1 spec/recipes/sync_spec.rb