Sha256: f34304bb4f68e2022d4af6d7a0e33b47f00ba702e5c884ed82cb52eee58d30de

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require File.join(File.dirname(__FILE__), '..','..','..','glycerin' )
require 'test/unit'
require 'og'

class TCOg_setup < Test::Unit::TestCase # :nodoc: all
  MockManager=Struct.new :options, :manage_classes, :post_setup

  def test_default
    manager = Og.start
    assert_instance_of Og::Manager, manager
    assert_equal :sqlite, manager.options[:adapter]
    assert_equal 'data', manager.options[:name]
    assert_equal true, manager.options[:called_by_og_setup]
  end

  def test_mattrs_initialized
    manager = Og.start
    assert_equal manager,Og.manager
    assert Og.thread_safe
  end  

  def test_missing_store
# gmosx: this test is not needed, Og catches and reports this
# error.
#   assert_raises(LoadError) { Og.start(:adapter => :missing) }
  end  

  def test_setup_default_store_plus_options
    manager = Og.start(:evolve_schema => true)
    assert_instance_of Og::Manager, manager
    assert_equal :sqlite, manager.options[:adapter]
    assert_equal true, manager.options[:evolve_schema]
  end

  def test_calls_manager_methods
    mock_manager = Struct.new(:options, :called) do 
      def manage_classes(*args)
        self.called = [:mc]
      end
      def post_setup
        self.called << :ps
      end
    end
    old = Og::Manager
    Og.const_set :Manager, mock_manager
    manager = Og.start
    assert_equal [:mc, :ps], manager.called
    Og.const_set :Manager, old
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.41.0 test/og/tc_setup.rb
og-0.40.0 test/og/tc_setup.rb