To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 75 / 7537e9eba2daabb99d2e6fee47a3f35857d9e159.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (1.46 KB)
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|---|---|
| 2 |
|
| 3 |
class ArbitraryCodeMixingTest < Test::Unit::TestCase |
| 4 |
def setup |
| 5 |
Engines.code_mixing_file_types = %w(controller helper) |
| 6 |
end |
| 7 |
|
| 8 |
def test_should_allow_setting_of_different_code_mixing_file_types |
| 9 |
assert_nothing_raised {
|
| 10 |
Engines.mix_code_from :things |
| 11 |
} |
| 12 |
end |
| 13 |
|
| 14 |
def test_should_add_new_types_to_existing_code_mixing_file_types |
| 15 |
Engines.mix_code_from :things |
| 16 |
assert_equal ["controller", "helper", "thing"], Engines.code_mixing_file_types |
| 17 |
Engines.mix_code_from :other |
| 18 |
assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types |
| 19 |
end |
| 20 |
|
| 21 |
def test_should_allow_setting_of_multiple_types_at_once |
| 22 |
Engines.mix_code_from :things, :other |
| 23 |
assert_equal ["controller", "helper", "thing", "other"], Engines.code_mixing_file_types |
| 24 |
end |
| 25 |
|
| 26 |
def test_should_singularize_elements_to_be_mixed |
| 27 |
# this is the only test using mocha, so let's try to work around it |
| 28 |
# also, this seems to be already tested with the :things in the tests above |
| 29 |
# arg = stub(:to_s => stub(:singularize => "element")) |
| 30 |
Engines.mix_code_from :elements |
| 31 |
assert Engines.code_mixing_file_types.include?("element")
|
| 32 |
end |
| 33 |
|
| 34 |
# TODO doesn't seem to work as expected? |
| 35 |
|
| 36 |
# def test_should_successfully_mix_custom_types |
| 37 |
# Engines.mix_code_from :things |
| 38 |
# assert_equal 'Thing (from app)', Thing.from_app |
| 39 |
# assert_equal 'Thing (from test_code_mixing)', Thing.from_plugin |
| 40 |
# end |
| 41 |
end |