Sha256: 96604c221bae1dbf7f0de52121b402a6fc02ad4c16993b9e7ee99a1826d1132c

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'assert'
require 'dk-dumpdb/task/teardown'

require 'test/support/task/internal_task'

class Dk::Dumpdb::Task::Teardown

  class UnitTests < Assert::Context
    desc "Dk::Dumpdb::Task::Teardown"
    setup do
      @task_class = Dk::Dumpdb::Task::Teardown
    end
    subject{ @task_class}

    should "be an internal task" do
      assert_includes Dk::Dumpdb::Task::InternalTask, subject
    end

    should "know its description" do
      exp = "(dk-dumpdb) teardown a script run"
      assert_equal exp, subject.description
    end

  end

  class InitTests < UnitTests
    include Dk::Dumpdb::Task::InternalTask::TestHelpers

    desc "when init"
    setup do
      now = Factory.time
      Assert.stub(Time, :now){ now }

      set_dk_dumpdb_script_param
      @runner = test_runner(@task_class, :params => @params)
    end

  end

  class RunTests < InitTests
    desc "and run"
    setup do
      @runner.run
    end
    subject{ @runner }

    should "run 2 cmds" do
      assert_equal 2, subject.runs.size
      rmdir_src, rmdir_targ = subject.runs

      exp = @params['script'].dump_cmd{ "rm -rf #{source.output_dir}" }
      assert_equal exp, rmdir_src.cmd_str

      exp = @params['script'].restore_cmd{ "rm -rf #{target.output_dir}" }
      assert_equal exp, rmdir_targ.cmd_str
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dk-dumpdb-0.1.0 test/unit/task/teardown_tests.rb