diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-03-03 19:10:42 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-03-03 19:10:42 -0800 |
commit | 8ef46f0d61c5e4a2b92708585a5157dac96a6817 (patch) | |
tree | a828e6cc95e3f3ab8a055304e3fcff90f3df889c /railties/test/metal_test.rb | |
parent | cb534524389bb4f407fc268a0bb7a7cffb6785a9 (diff) | |
parent | ce56c5daa81d61a745b88220014a846a0eea46a4 (diff) | |
download | rails-8ef46f0d61c5e4a2b92708585a5157dac96a6817.tar.gz rails-8ef46f0d61c5e4a2b92708585a5157dac96a6817.tar.bz2 rails-8ef46f0d61c5e4a2b92708585a5157dac96a6817.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'railties/test/metal_test.rb')
-rw-r--r-- | railties/test/metal_test.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb new file mode 100644 index 0000000000..cff231ed00 --- /dev/null +++ b/railties/test/metal_test.rb @@ -0,0 +1,57 @@ +require 'abstract_unit' +require 'initializer' + +class MetalTest < Test::Unit::TestCase + def test_metals_should_return_list_of_found_metal_apps + use_appdir("singlemetal") do + assert_equal(["FooMetal"], found_metals_as_string_array) + end + end + + def test_metals_should_return_alphabetical_list_of_found_metal_apps + use_appdir("multiplemetals") do + assert_equal(["MetalA", "MetalB"], found_metals_as_string_array) + end + end + + def test_metals_load_order_should_be_overriden_by_requested_metals + use_appdir("multiplemetals") do + Rails::Rack::Metal.requested_metals = ["MetalB", "MetalA"] + assert_equal(["MetalB", "MetalA"], found_metals_as_string_array) + end + end + + def test_metals_not_listed_should_not_load + use_appdir("multiplemetals") do + Rails::Rack::Metal.requested_metals = ["MetalB"] + assert_equal(["MetalB"], found_metals_as_string_array) + end + end +p + def test_metal_finding_should_work_with_subfolders + use_appdir("subfolders") do + assert_equal(["Folder::MetalA", "Folder::MetalB"], found_metals_as_string_array) + end + end + + def test_metal_finding_with_requested_metals_should_work_with_subfolders + use_appdir("subfolders") do + Rails::Rack::Metal.requested_metals = ["Folder::MetalB"] + assert_equal(["Folder::MetalB"], found_metals_as_string_array) + end + end + + private + + def use_appdir(root) + dir = "#{File.dirname(__FILE__)}/fixtures/metal/#{root}" + Rails::Rack::Metal.metal_paths = ["#{dir}/app/metal"] + Rails::Rack::Metal.requested_metals = nil + $LOAD_PATH << "#{dir}/app/metal" + yield + end + + def found_metals_as_string_array + Rails::Rack::Metal.metals.map { |m| m.to_s } + end +end |