view vendor/plugins/engines/test/unit/arbitrary_code_mixing_test.rb @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children
line wrap: on
line source
require File.dirname(__FILE__) + '/../test_helper'

class ArbitraryCodeMixingTest < Test::Unit::TestCase  
  def setup
    Engines.code_mixing_file_types = %w(controller helper)
  end
  
  def test_should_allow_setting_of_different_code_mixing_file_types
    assert_nothing_raised {
      Engines.mix_code_from :things
    }
  end

  def test_should_add_new_types_to_existing_code_mixing_file_types
    Engines.mix_code_from :things
    assert_equal ["controller", "helper", "thing"], Engines.code_mixing_file_types
    Engines.mix_code_from :other
    assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types
  end
  
  def test_should_allow_setting_of_multiple_types_at_once
    Engines.mix_code_from :things, :other
    assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types
  end
   
  def test_should_singularize_elements_to_be_mixed
    # this is the only test using mocha, so let's try to work around it
    # also, this seems to be already tested with the :things in the tests above
    # arg = stub(:to_s => stub(:singularize => "element")) 
    Engines.mix_code_from :elements
    assert Engines.code_mixing_file_types.include?("element")
  end
  
  # TODO doesn't seem to work as expected?
  
  # def test_should_successfully_mix_custom_types
  #   Engines.mix_code_from :things    
  #   assert_equal 'Thing (from app)', Thing.from_app
  #   assert_equal 'Thing (from test_code_mixing)', Thing.from_plugin
  # end
end