Sha256: 2964741eadbf9178db3249ed93d9bb02c3f0591489def48ab3b2de754109f02c
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require 'spec_helper' describe Dbcp::Cli do subject { Dbcp::Cli.new silent_stdout } let(:silent_stdout) { '/dev/null' } before { Dir.chdir lib = File.expand_path('../../../fixtures', __FILE__) } describe "#start" do context "success" do let(:source) { double 'Dbcp::Environment', database: double(adapter: 'postgres'), environment_name: 'staging' } let(:destination) { double 'Dbcp::Environment', database: double(adapter: 'postgres'), environment_name: 'development' } let(:source_snapshot_file) { double 'Dbcp::DatabaseSnapshotFile.new', path: '/tmp/foo', transfer_to: destination_snapshot_file } let(:destination_snapshot_file) { double 'Dbcp::DatabaseSnapshotFile.new', path: '/tmp/bar' } before do allow(Dbcp::Environment).to receive(:find).with('staging') { source } allow(Dbcp::Environment).to receive(:find).with('development') { destination } end it "clones the database" do expect(source).to receive(:export) { source_snapshot_file } expect(destination).to receive(:import).with(destination_snapshot_file) expect(source_snapshot_file).to receive(:delete) expect(destination_snapshot_file).to receive(:delete) subject.start ['staging'] end end context "too few arguments" do it "exits" do expect { subject.start [] }.to raise_error(SystemExit) end end context "two different database types" do it "exist" do expect { subject.start ['development', 'sqlite'] }.to raise_error(SystemExit) end end context "environments are the same" do it "exits" do expect { subject.start ['development', 'development'] }.to raise_error(SystemExit) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dbcp-0.0.1 | spec/lib/dbcp/cli_spec.rb |