Sha256: e13f629e8f480d37e51b4322ac361b61950d06049266a462d860c81f86e39d0c

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

require 'test/helper'

class TypusTest < ActiveSupport::TestCase

  def test_should_return_version
    assert Typus.respond_to?(:version)
    assert Typus.version.kind_of?(String)
  end

  def test_should_return_path
    expected = Dir.pwd + '/lib/../'
    assert_equal expected, Typus.root
  end

  def test_should_return_applications_and_should_be_sorted
    assert Typus.respond_to?(:applications)
    assert Typus.applications.kind_of?(Array)
    assert_equal %w( Blog Site Typus ), Typus.applications
  end

  def test_should_return_modules_of_an_application
    assert Typus.respond_to?(:application)
    assert_equal %w( Comment Post ), Typus.application('Blog')
  end

  def test_should_return_models_and_should_be_sorted
    assert Typus.respond_to?(:models)
    assert Typus.models.kind_of?(Array)
    assert_equal %w( Asset Category Comment CustomUser Page Post TypusUser ), Typus.models
  end

  def test_should_return_an_array_of_models_on_header
    assert Typus.models_on_header.kind_of?(Array)
    assert_equal ["Page"], Typus.models_on_header
  end

  def test_should_verify_resources_class_method
    assert Typus.respond_to?(:resources)
    models = Typus.models
    assert_equal %w( Git Order Status WatchDog ), Typus.resources(models)
  end

  def test_should_verify_enable_exists
    assert Typus.respond_to?(:enable)
  end

  def test_should_verify_enable_exists
    assert Typus.respond_to?(:generator)
  end

  def test_should_return_user_class
    assert_equal TypusUser, Typus.user_class
  end

  def test_should_return_overwritted_user_class
    options = { :user_class_name => 'CustomUser' }
    Typus::Configuration.stubs(:options).returns(options)
    assert_equal CustomUser, Typus.user_class
  end

  def test_should_return_user_fk
    assert_equal 'typus_user_id', Typus.user_fk
  end

  def test_should_return_overwritted_user_fk
    options = { :user_fk => 'my_user_fk' }
    Typus::Configuration.stubs(:options).returns(options)
    assert_equal 'my_user_fk', Typus.user_fk
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typus-0.9.27 test/lib/typus_test.rb
typus-0.9.26 test/lib/typus_test.rb