aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2009-10-21 15:45:11 -0700
committerCarl Lerche <carllerche@mac.com>2009-10-21 15:46:22 -0700
commit8a0f4564432bef9dde815dd6b768d088cfad16ed (patch)
treefad65c831ba2d1a11e0bcccf949c01c3fbfb0bad /railties
parent3e35d30c0cab711fcc9feddd23f2f682f5d0a050 (diff)
downloadrails-8a0f4564432bef9dde815dd6b768d088cfad16ed.tar.gz
rails-8a0f4564432bef9dde815dd6b768d088cfad16ed.tar.bz2
rails-8a0f4564432bef9dde815dd6b768d088cfad16ed.zip
Refactored railties' isolation tests to be able to run script/* scripts.
Diffstat (limited to 'railties')
-rw-r--r--railties/test/isolation/abstract_unit.rb17
-rw-r--r--railties/test/plugins/vendored_test.rb19
2 files changed, 32 insertions, 4 deletions
diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb
index 11cabb2c0b..462a4d8dea 100644
--- a/railties/test/isolation/abstract_unit.rb
+++ b/railties/test/isolation/abstract_unit.rb
@@ -81,7 +81,6 @@ module TestHelpers
def build_app(options = {})
FileUtils.rm_rf(app_path)
FileUtils.cp_r(tmp_path('app_template'), app_path)
- FileUtils.ln_s(RAILS_FRAMEWORK_ROOT, app_path('vendor/rails'))
# Delete the initializers unless requested
unless options[:initializers]
@@ -93,6 +92,12 @@ module TestHelpers
add_to_config 'config.action_controller.session = { :key => "_myapp_session", :secret => "bac838a849c1d5c4de2e6a50af826079" }'
end
+ def script(script)
+ Dir.chdir(app_path) do
+ `#{Gem.ruby} #{app_path}/script/#{script}`
+ end
+ end
+
def add_to_config(str)
environment = File.read("#{app_path}/config/application.rb")
if environment =~ /(\n\s*end\s*)\Z/
@@ -149,8 +154,12 @@ Module.new do
if File.exist?(tmp_path)
FileUtils.rm_rf(tmp_path)
end
-
FileUtils.mkdir(tmp_path)
- root = File.expand_path('../../../..', __FILE__)
- `#{Gem.ruby} -r #{root}/vendor/gems/environment #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails #{tmp_path('app_template')}`
+
+ environment = File.expand_path('../../../../vendor/gems/environment', __FILE__)
+
+ `#{Gem.ruby} -r #{environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails #{tmp_path('app_template')}`
+ File.open("#{tmp_path}/app_template/config/boot.rb", 'w') do |f|
+ f.puts "require '#{environment}' ; require 'rails'"
+ end
end
diff --git a/railties/test/plugins/vendored_test.rb b/railties/test/plugins/vendored_test.rb
new file mode 100644
index 0000000000..71de542ff7
--- /dev/null
+++ b/railties/test/plugins/vendored_test.rb
@@ -0,0 +1,19 @@
+require "isolation/abstract_unit"
+
+module ApplicationTests
+ class PluginTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Isolation
+
+ def setup
+ build_app
+ end
+
+ test "generates the plugin" do
+ script "generate plugin my_plugin"
+ File.open("#{app_path}/vendor/plugins/my_plugin/init.rb", 'w') do |f|
+ f.puts "OMG = 'hello'"
+ end
+ require "#{app_path}/config/environment"
+ end
+ end
+end \ No newline at end of file