Chris@909: require File.dirname(__FILE__) + '/../test_helper' Chris@909: Chris@909: class ArbitraryCodeMixingTest < Test::Unit::TestCase Chris@909: def setup Chris@909: Engines.code_mixing_file_types = %w(controller helper) Chris@909: end Chris@909: Chris@909: def test_should_allow_setting_of_different_code_mixing_file_types Chris@909: assert_nothing_raised { Chris@909: Engines.mix_code_from :things Chris@909: } Chris@909: end Chris@909: Chris@909: def test_should_add_new_types_to_existing_code_mixing_file_types Chris@909: Engines.mix_code_from :things Chris@909: assert_equal ["controller", "helper", "thing"], Engines.code_mixing_file_types Chris@909: Engines.mix_code_from :other Chris@909: assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types Chris@909: end Chris@909: Chris@909: def test_should_allow_setting_of_multiple_types_at_once Chris@909: Engines.mix_code_from :things, :other Chris@909: assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types Chris@909: end Chris@909: Chris@909: def test_should_singularize_elements_to_be_mixed Chris@909: # this is the only test using mocha, so let's try to work around it Chris@909: # also, this seems to be already tested with the :things in the tests above Chris@909: # arg = stub(:to_s => stub(:singularize => "element")) Chris@909: Engines.mix_code_from :elements Chris@909: assert Engines.code_mixing_file_types.include?("element") Chris@909: end Chris@909: Chris@909: # TODO doesn't seem to work as expected? Chris@909: Chris@909: # def test_should_successfully_mix_custom_types Chris@909: # Engines.mix_code_from :things Chris@909: # assert_equal 'Thing (from app)', Thing.from_app Chris@909: # assert_equal 'Thing (from test_code_mixing)', Thing.from_plugin Chris@909: # end Chris@909: end