aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2011-06-06 17:17:37 +1000
committerStefan Sprenger <stefan.sprenger@dkd.de>2011-06-07 08:31:19 +0200
commit32d35bac09a2d9c86d8893384959c7811df50130 (patch)
tree1d1b3dcd89f96d25294dc407fae43e551b5ac43a /railties/test
parentfd59a3a1d7d81f6a9b54e2f958b78d929f6db9fc (diff)
downloadrails-32d35bac09a2d9c86d8893384959c7811df50130.tar.gz
rails-32d35bac09a2d9c86d8893384959c7811df50130.tar.bz2
rails-32d35bac09a2d9c86d8893384959c7811df50130.zip
Add beginnings of test for generators within the context of an engine
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/engine/generators_test.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/railties/test/engine/generators_test.rb b/railties/test/engine/generators_test.rb
new file mode 100644
index 0000000000..6b2c83275b
--- /dev/null
+++ b/railties/test/engine/generators_test.rb
@@ -0,0 +1,54 @@
+# require 'isolation/abstract_unit'
+
+require 'fileutils'
+
+require 'test/unit'
+require 'rubygems'
+
+# TODO: Remove setting this magic constant
+RAILS_FRAMEWORK_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../..")
+
+# These files do not require any others and are needed
+# to run the tests
+require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/testing/isolation"
+require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/testing/declarative"
+require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/core_ext/kernel/reporting"
+require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/rails/generators/test_case"
+
+module EngineTests
+ class ControllerGenerator < Rails::Generators::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ TMP_PATH = File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. tmp]))
+ self.destination_root = File.join(TMP_PATH, "foo_bar")
+
+ def tmp_path(*args)
+ File.join(TMP_PATH, *args)
+ end
+
+ def engine_path
+ tmp_path('foo_bar')
+ end
+
+ def build_engine
+ FileUtils.mkdir_p(engine_path)
+ FileUtils.rm_r(engine_path)
+ environment = File.expand_path('../../../../load_paths', __FILE__)
+ if File.exist?("#{environment}.rb")
+ require_environment = "-r #{environment}"
+ end
+ `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/bin/rails plugin new #{engine_path} --full --mountable`
+ end
+
+ def setup
+ build_engine
+ end
+
+ def test_omg
+ Dir.chdir(engine_path) do
+ `rails g controller topics`
+ assert_file "app/controllers/foo_bar/topics_controller.rb"
+ end
+ end
+ end
+end