Correct engine tests to work on Ruby 1.9 #952 #944

This commit is contained in:
Jan Vlnas 2012-03-26 10:32:48 +02:00 committed by Felix Schäfer
parent 6932070752
commit 29af3ec964
4 changed files with 26 additions and 4 deletions

View File

@ -125,7 +125,7 @@ namespace :test do
end.to_yaml)
end
out.puts " installing exception_notification plugin"
run "cd #{test_app_dir} && ./script/plugin install git://github.com/rails/exception_notification.git"
run "cd #{test_app_dir} && ./script/plugin install git://github.com/rails/exception_notification.git -r 'tag pre-2-3'"
end
end
@ -201,6 +201,7 @@ namespace :test do
mirror_test_files('plugins', 'vendor')
mirror_test_files('unit', 'test')
mirror_test_files('functional', 'test')
mirror_test_files('initializers', 'config')
end
desc 'Prepare the engines test environment'

View File

@ -54,7 +54,7 @@ require 'fileutils'
#
module Engines::Testing
mattr_accessor :temporary_fixtures_directory
self.temporary_fixtures_directory = FileUtils.mkdir_p(File.join(Dir.tmpdir, "rails_fixtures"))
self.temporary_fixtures_directory = [*FileUtils.mkdir_p(File.join(Dir.tmpdir, "rails_fixtures"))].first
# Copies fixtures from plugins and the application into a temporary directory
# (Engines::Testing.temporary_fixtures_directory).
@ -99,4 +99,4 @@ module Engines::Testing
test_kind, plugin_name, File.basename(filename)))
load(override_file) if File.exist?(override_file)
end
end
end

View File

@ -0,0 +1,4 @@
#-- encoding: UTF-8
# Fixes Rails 2.3 and Ruby 1.9.x incompatibility
# See https://groups.google.com/d/topic/rubyonrails-core/gb5woRkmDlk/discussion
MissingSourceFile::REGEXPS << [/^cannot load such file -- (.+)$/i, 1]

View File

@ -10,6 +10,9 @@ class TestingTest < Test::Unit::TestCase
def teardown
File.delete(@filename) if File.exists?(@filename)
if File.directory?(Engines::Testing.temporary_fixtures_directory)
FileUtils.rm_r(Engines::Testing.temporary_fixtures_directory)
end
end
def test_should_copy_fixtures_files_to_tmp_directory
@ -17,4 +20,18 @@ class TestingTest < Test::Unit::TestCase
Engines::Testing.setup_plugin_fixtures
assert File.exists?(@filename)
end
end
def test_creates_temporary_fixtures_directory
assert File.directory?(Engines::Testing.temporary_fixtures_directory)
end
def test_set_fixture_path_doesnt_break_load_path
assert_nothing_raised "require has failed after call to Engines::Testing.set_fixture_path" do
require 'tmpdir' # XXX this can be anything, even loaded file
end
end
def test_fixtures_are_in_load_path
assert $LOAD_PATH.include?(Engines::Testing.temporary_fixtures_directory)
end
end