Sha256: 768fd14d7113ffeb144b3823d704f64a71b351624d504217842985b7f8c3278b

Contents?: true

Size: 1.69 KB

Versions: 15

Compression:

Stored size: 1.69 KB

Contents

require 'assert'
require 'ns-options/assert_macros'
require 'ardb'

class Ardb::Config

  class BaseTests < Assert::Context
    include NsOptions::AssertMacros
    desc "Ardb::Config"
    subject{ Ardb::Config }

    should have_namespace :db
    should have_option  :db_file,   Pathname, :default => ENV['ARDB_DB_FILE']
    should have_option  :root_path, Pathname, :required => true
    should have_option  :logger, :required => true
    should have_options :migrations_path, :schema_path
    should have_imeth   :db_settings

    should "should use `db/migrations` as the default migrations path" do
      exp_path = Pathname.new(TESTDB_PATH).join("db/migrations").to_s
      assert_equal exp_path, subject.migrations_path
    end

    should "should use `db/schema.rb` as the default schema path" do
      exp_path = Pathname.new(TESTDB_PATH).join("db/schema.rb").to_s
      assert_equal exp_path, subject.schema_path
    end

    should "build the db connection settings from the db configs" do
      # returns only non-nil values with string keys
      exp = {
        'adapter'  => "postgresql",
        'database' => "ardbtest"
      }
      assert_equal exp, subject.db_settings
    end

  end

  class DbTests < BaseTests
    desc "db namespace"
    subject{ Ardb::Config.db }

    should have_option :adapter,  String,  :required => true
    should have_option :database, String,  :required => true
    should have_option :encoding, String,  :required => false
    should have_option :host,     String,  :required => false
    should have_option :port,     Integer, :required => false
    should have_option :username, String,  :required => false
    should have_option :password, String,  :required => false

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ardb-0.20.0 test/unit/config_tests.rb
ardb-0.19.0 test/unit/config_tests.rb
ardb-0.18.0 test/unit/config_tests.rb
ardb-0.17.0 test/unit/config_tests.rb
ardb-0.16.0 test/unit/config_tests.rb
ardb-0.15.0 test/unit/config_tests.rb
ardb-0.14.0 test/unit/config_tests.rb
ardb-0.13.0 test/unit/config_tests.rb
ardb-0.12.0 test/unit/config_tests.rb
ardb-0.11.0 test/unit/config_tests.rb
ardb-0.10.0 test/unit/config_tests.rb
ardb-0.9.0 test/unit/config_tests.rb
ardb-0.8.0 test/unit/config_tests.rb
ardb-0.7.0 test/unit/config_tests.rb
ardb-0.6.0 test/unit/config_tests.rb