annotate 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
rev   line source
Chris@0 1 require File.dirname(__FILE__) + '/../test_helper'
Chris@0 2
Chris@0 3 class ArbitraryCodeMixingTest < Test::Unit::TestCase
Chris@0 4 def setup
Chris@0 5 Engines.code_mixing_file_types = %w(controller helper)
Chris@0 6 end
Chris@0 7
Chris@0 8 def test_should_allow_setting_of_different_code_mixing_file_types
Chris@0 9 assert_nothing_raised {
Chris@0 10 Engines.mix_code_from :things
Chris@0 11 }
Chris@0 12 end
Chris@0 13
Chris@0 14 def test_should_add_new_types_to_existing_code_mixing_file_types
Chris@0 15 Engines.mix_code_from :things
Chris@0 16 assert_equal ["controller", "helper", "thing"], Engines.code_mixing_file_types
Chris@0 17 Engines.mix_code_from :other
Chris@0 18 assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types
Chris@0 19 end
Chris@0 20
Chris@0 21 def test_should_allow_setting_of_multiple_types_at_once
Chris@0 22 Engines.mix_code_from :things, :other
Chris@0 23 assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types
Chris@0 24 end
Chris@0 25
Chris@0 26 def test_should_singularize_elements_to_be_mixed
Chris@0 27 # this is the only test using mocha, so let's try to work around it
Chris@0 28 # also, this seems to be already tested with the :things in the tests above
Chris@0 29 # arg = stub(:to_s => stub(:singularize => "element"))
Chris@0 30 Engines.mix_code_from :elements
Chris@0 31 assert Engines.code_mixing_file_types.include?("element")
Chris@0 32 end
Chris@0 33
Chris@0 34 # TODO doesn't seem to work as expected?
Chris@0 35
Chris@0 36 # def test_should_successfully_mix_custom_types
Chris@0 37 # Engines.mix_code_from :things
Chris@0 38 # assert_equal 'Thing (from app)', Thing.from_app
Chris@0 39 # assert_equal 'Thing (from test_code_mixing)', Thing.from_plugin
Chris@0 40 # end
Chris@0 41 end