Sha256: 4936f831fa25764ab4486b758068b9faa86bfa41eb28070cd8306cd074a48d8a

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8

require File.expand_path('../../spec_helper.rb', __FILE__)

describe Backup::Database::Base do
  let(:model) { Backup::Model.new('foo', 'foo') }
  let(:db) { Backup::Database::Base.new(model) }

  it 'should set #utility_path' do
    db.utility_path.should be_nil
    db.utility_path = 'utility path'
    db.utility_path.should == 'utility path'
  end

  describe '#perform!' do
    it 'should invoke prepare! and log!' do
      s = sequence ''
      db.expects(:prepare!).in_sequence(s)
      db.expects(:log!).in_sequence(s)

      db.perform!
    end
  end

  context 'since CLI::Helpers are included' do
    it 'should respond to the #utility method' do
      db.respond_to?(:utility).should be_true
    end
  end

  describe '#prepare!' do
    it 'should set and create #dump_path' do
      model = stub(:trigger => 'test_trigger')
      db.instance_variable_set(:@model, model)
      FileUtils.expects(:mkdir_p).with(
        File.join(Backup::Config.tmp_path, 'test_trigger', 'databases', 'Base')
      )
      db.send(:prepare!)
      db.instance_variable_get(:@dump_path).should ==
        File.join(Backup::Config.tmp_path, 'test_trigger', 'databases', 'Base')
    end
  end

  describe '#log!' do
    it 'should use #database_name' do
      db.stubs(:name).returns('database_name')
      Backup::Logger.expects(:message).with(
        "Database::Base started dumping and archiving 'database_name'."
      )

      db.send(:log!)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
backup_checksum-3.0.23 spec/database/base_spec.rb
backup-3.0.23 spec/database/base_spec.rb
backup-3.0.22 spec/database/base_spec.rb
backup-3.0.21 spec/database/base_spec.rb