Sha256: 85f4020c5fc51e8fa57a1785ce36c2f3ab1c9fea078d02cbb7e999035e818278
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
require 'assert' require 'ardb' module Ardb class UnitTests < Assert::Context desc "Ardb" setup do @orig_ar_logger = ActiveRecord::Base.logger Adapter.reset @module = Ardb end teardown do Adapter.reset ActiveRecord::Base.logger = @orig_ar_logger end subject{ @module } should have_imeths :config, :configure, :adapter, :validate!, :init should have_imeths :escape_like_pattern should "return its `Config` class with the `config` method" do assert_same Config, subject.config end should "complain if init'ing and not all configs are set" do orig_adapter = Ardb.config.db.adapter Ardb.config.db.adapter = nil assert_raises(NotConfiguredError){ subject.init } Ardb.config.db.adapter = orig_adapter end should "init the adapter on init" do assert_nil Adapter.current begin subject.init rescue LoadError end assert_not_nil Adapter.current exp_adapter = Adapter.send(subject.config.db.adapter) assert_equal exp_adapter, Adapter.current assert_same Adapter.current, subject.adapter end should "establish an AR connection on init" do assert_raises(LoadError) do # not going to test this b/c I don't want to bring in all the crap it # takes to actually establish a connection with AR (adapters, etc) # plus, most of this should be handled by AR, ns-options, and the above # tests anyway subject.init end end end class InitTests < UnitTests desc "when init" setup do # don't establish connection, otherwise this errors if it can't connect to # an actual DB @module.init(false) end should "demeter its adapter" do pattern = "%#{Factory.string}\\#{Factory.string}_" exp = subject.adapter.escape_like_pattern(pattern) assert_equal exp, subject.escape_like_pattern(pattern) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ardb-0.27.3 | test/unit/ardb_tests.rb |