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