Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored railties' isolation tests to be able to run script/* scripts.

  • Loading branch information...
commit 8a0f4564432bef9dde815dd6b768d088cfad16ed 1 parent 3e35d30
Carl Lerche authored
17 railties/test/isolation/abstract_unit.rb
View
@@ -81,7 +81,6 @@ module Generation
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 @@ def build_app(options = {})
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 @@ class Test::Unit::TestCase
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
19 railties/test/plugins/vendored_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.