aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/railties
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-26 14:58:00 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-26 14:58:00 +0100
commitf8bf1982dff9cf0f35fb7a121932c794ecdc1cb1 (patch)
tree04145ec0b4a3dae8d55bb3f31ce533708a015f20 /railties/test/railties
parent7adb1ffc038e06a1c95030856859e183b181f94a (diff)
downloadrails-f8bf1982dff9cf0f35fb7a121932c794ecdc1cb1.tar.gz
rails-f8bf1982dff9cf0f35fb7a121932c794ecdc1cb1.tar.bz2
rails-f8bf1982dff9cf0f35fb7a121932c794ecdc1cb1.zip
Add tests for explicit engines.
Diffstat (limited to 'railties/test/railties')
-rw-r--r--railties/test/railties/engine_test.rb23
-rw-r--r--railties/test/railties/plugin_test.rb41
-rw-r--r--railties/test/railties/shared_tests.rb51
3 files changed, 73 insertions, 42 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
new file mode 100644
index 0000000000..374f5ea93c
--- /dev/null
+++ b/railties/test/railties/engine_test.rb
@@ -0,0 +1,23 @@
+require "isolation/abstract_unit"
+require "railties/shared_tests"
+
+module RailtiesTest
+ class EngineTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+ include SharedTests
+
+ def setup
+ build_app
+
+ @plugin = engine "bukkits" do |plugin|
+ plugin.write "lib/bukkits.rb", <<-RUBY
+ class Bukkits
+ class Engine < ::Rails::Engine
+ end
+ end
+ RUBY
+ plugin.write "lib/another.rb", "class Another; end"
+ end
+ end
+ end
+end
diff --git a/railties/test/railties/plugin_test.rb b/railties/test/railties/plugin_test.rb
index adcc5431f6..0adc31e3ed 100644
--- a/railties/test/railties/plugin_test.rb
+++ b/railties/test/railties/plugin_test.rb
@@ -2,7 +2,7 @@ require "isolation/abstract_unit"
require "railties/shared_tests"
module RailtiesTest
- class PluginSpecificTest < Test::Unit::TestCase
+ class PluginTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
include SharedTests
@@ -11,9 +11,16 @@ module RailtiesTest
@plugin = plugin "bukkits", "::LEVEL = config.log_level" do |plugin|
plugin.write "lib/bukkits.rb", "class Bukkits; end"
+ plugin.write "lib/another.rb", "class Another; end"
end
end
+ test "plugin can load the file with the same name in lib" do
+ boot_rails
+ require "bukkits"
+ assert_equal "Bukkits", Bukkits.name
+ end
+
test "it loads the plugin's init.rb file" do
boot_rails
assert_equal "loaded", BUKKITS
@@ -24,6 +31,20 @@ module RailtiesTest
assert_equal :debug, LEVEL
end
+ test "plugin_init_is_ran_before_application_ones" do
+ plugin "foo", "$foo = true" do |plugin|
+ plugin.write "lib/foo.rb", "module Foo; end"
+ end
+
+ app_file 'config/initializers/foo.rb', <<-RUBY
+ raise "no $foo" unless $foo
+ raise "no Foo" unless Foo
+ RUBY
+
+ boot_rails
+ assert $foo
+ end
+
test "plugin should work without init.rb" do
@plugin.delete("init.rb")
@@ -56,5 +77,23 @@ module RailtiesTest
assert rescued, "Expected boot rails to fail"
end
+
+ test "deprecated tasks are also loaded" do
+ $executed = false
+ @plugin.write "tasks/foo.rake", <<-RUBY
+ task :foo do
+ $executed = true
+ end
+ RUBY
+
+ boot_rails
+ require 'rake'
+ require 'rake/rdoctask'
+ require 'rake/testtask'
+ Rails.application.load_tasks
+ Rake::Task[:foo].invoke
+ assert $executed
+ end
+
end
end
diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb
index ab6ab0a215..a20aa5e4f5 100644
--- a/railties/test/railties/shared_tests.rb
+++ b/railties/test/railties/shared_tests.rb
@@ -12,35 +12,21 @@ module RailtiesTest
def test_plugin_puts_its_lib_directory_on_load_path
boot_rails
- require "bukkits"
- assert_equal "Bukkits", Bukkits.name
- end
-
- def test_plugin_init_is_ran_before_application_ones
- plugin "foo", "$foo = true" do |plugin|
- plugin.write "lib/foo.rb", "module Foo; end"
- end
-
- app_file 'config/initializers/foo.rb', <<-RUBY
- raise "no $foo" unless $foo
- raise "no Foo" unless Foo
- RUBY
-
- boot_rails
- assert $foo
+ require "another"
+ assert_equal "Another", Another.name
end
def test_plugin_paths_get_added_to_as_dependency_list
boot_rails
- assert_equal "Bukkits", Bukkits.name
+ assert_equal "Another", Another.name
end
def test_plugins_constants_are_not_reloaded_by_default
boot_rails
- assert_equal "Bukkits", Bukkits.name
+ assert_equal "Another", Another.name
ActiveSupport::Dependencies.clear
- @plugin.delete("lib/bukkits.rb")
- assert_nothing_raised { Bukkits }
+ @plugin.delete("lib/another.rb")
+ assert_nothing_raised { Another }
end
def test_plugin_constants_get_reloaded_if_config_reload_plugins
@@ -50,10 +36,10 @@ module RailtiesTest
boot_rails
- assert_equal "Bukkits", Bukkits.name
+ assert_equal "Another", Another.name
ActiveSupport::Dependencies.clear
- @plugin.delete("lib/bukkits.rb")
- assert_raises(NameError) { Bukkits }
+ @plugin.delete("lib/another.rb")
+ assert_raises(NameError) { Another }
end
def test_plugin_puts_its_models_directory_on_load_path
@@ -190,23 +176,6 @@ module RailtiesTest
assert $executed
end
- def test_deprecated_tasks_are_also_loaded
- $executed = false
- @plugin.write "tasks/foo.rake", <<-RUBY
- task :foo do
- $executed = true
- end
- RUBY
-
- boot_rails
- require 'rake'
- require 'rake/rdoctask'
- require 'rake/testtask'
- Rails.application.load_tasks
- Rake::Task[:foo].invoke
- assert $executed
- end
-
def test_i18n_files_have_lower_priority_than_application_ones
add_to_config <<-RUBY
config.i18n.load_path << "#{app_path}/app/locales/en.yml"
@@ -235,7 +204,7 @@ YAML
#{RAILS_FRAMEWORK_ROOT}/activemodel/lib/active_model/locale/en.yml
#{RAILS_FRAMEWORK_ROOT}/activerecord/lib/active_record/locale/en.yml
#{RAILS_FRAMEWORK_ROOT}/actionpack/lib/action_view/locale/en.yml
- #{app_path}/vendor/plugins/bukkits/config/locales/en.yml
+ #{@plugin.path}/config/locales/en.yml
#{app_path}/config/locales/en.yml
#{app_path}/app/locales/en.yml
).map { |path| File.expand_path(path) }, I18n.load_path.map { |path| File.expand_path(path) }