From 4d4d2c3896ed5a5d74da833c5c3132f406f4eab7 Mon Sep 17 00:00:00 2001 From: Simon Jefford Date: Tue, 3 Mar 2009 12:39:19 -0600 Subject: Enhanced Rails Metal - the load order of metals can now be configured [#2057 state:resolved] Signed-off-by: Joshua Peek --- railties/test/metal_test.rb | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 railties/test/metal_test.rb (limited to 'railties/test/metal_test.rb') 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 -- cgit v1.2.3 From 6087fe8eedf0249f74be10721714f5298286b198 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 4 Mar 2009 12:26:53 -0600 Subject: stray character in railties test --- railties/test/metal_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test/metal_test.rb') diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb index cff231ed00..a31f4ab273 100644 --- a/railties/test/metal_test.rb +++ b/railties/test/metal_test.rb @@ -27,7 +27,7 @@ class MetalTest < Test::Unit::TestCase 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) -- cgit v1.2.3 From e97180c273ada9b252ddf42d340d2947a509cb26 Mon Sep 17 00:00:00 2001 From: Simon Jefford Date: Thu, 5 Mar 2009 18:50:52 -0600 Subject: Ensure that loading metals from the main app and engines works on older Ruby versions [#2143 state:resolved] Signed-off-by: Joshua Peek --- railties/test/metal_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'railties/test/metal_test.rb') diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb index a31f4ab273..143efdda11 100644 --- a/railties/test/metal_test.rb +++ b/railties/test/metal_test.rb @@ -41,6 +41,15 @@ class MetalTest < Test::Unit::TestCase end end + def test_metal_finding_should_work_with_multiple_metal_paths_in_185_and_below + use_appdir("singlemetal") do + engine_metal_path = "#{File.dirname(__FILE__)}/fixtures/plugins/engines/engine/app/metal" + Rails::Rack::Metal.metal_paths << engine_metal_path + $LOAD_PATH << engine_metal_path + assert_equal(["FooMetal", "EngineMetal"], found_metals_as_string_array) + end + end + private def use_appdir(root) -- cgit v1.2.3