Sha256: ce4d9930ea45b15e1291aabaa3c4bf32772e37c98262df0cc13592f9a4aab098
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
require 'assert' require 'pathname' require 'active_record' require 'ardb/runner' class Ardb::Runner class BaseTests < Assert::Context desc "Ardb::Runner" setup do @runner = Ardb::Runner.new(['null', 1, 2], 'some' => 'opts') end subject{ @runner } should have_readers :cmd_name, :cmd_args, :opts should "know its cmd, cmd_args, and opts" do assert_equal 'null', subject.cmd_name assert_equal [1,2], subject.cmd_args assert_equal 'opts', subject.opts['some'] end end class RunTests < BaseTests desc "when running a command" setup do Ardb::Adapter.reset @runner = Ardb::Runner.new(['null', 1, 2], {}) end teardown do Ardb::Adapter.reset end should "validate the configs" do orig_adapter = Ardb.config.db.adapter Ardb.config.db.adapter = nil assert_raises(Ardb::NotConfiguredError) { subject.run } Ardb.config.db.adapter = orig_adapter end should "init the adapter" do assert_nil Ardb.adapter subject.run assert_not_nil Ardb.adapter end should "set the AR logger" do default_ar_logger = ActiveRecord::Base.logger subject.run assert_equal Ardb.config.logger, ActiveRecord::Base.logger ActiveRecord::Base.logger = default_ar_logger end should "add the working directory to the load paths" do $LOAD_PATH.delete(Dir.pwd) subject.run assert_includes Dir.pwd, $LOAD_PATH end should "complain about unknown cmds" do runner = Ardb::Runner.new(['unknown'], {}) assert_raises(UnknownCmdError) { runner.run } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ardb-0.20.0 | test/unit/runner_tests.rb |
ardb-0.19.0 | test/unit/runner_tests.rb |
ardb-0.18.0 | test/unit/runner_tests.rb |