diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-07-02 16:51:05 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-07-02 16:51:05 -0700 |
commit | d8406f0c20e7809ce797d37c509e2f58f07109d2 (patch) | |
tree | 86fc6723e3bab6ccc094a38b78b5c3b2c7cff4e3 /railties | |
parent | 1d280e21a19aff74e1b35779be2633e6efa511f0 (diff) | |
download | rails-d8406f0c20e7809ce797d37c509e2f58f07109d2.tar.gz rails-d8406f0c20e7809ce797d37c509e2f58f07109d2.tar.bz2 rails-d8406f0c20e7809ce797d37c509e2f58f07109d2.zip |
Wrote tests for the :check_ruby_version initializer
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/initializer/check_ruby_version_test.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/railties/test/initializer/check_ruby_version_test.rb b/railties/test/initializer/check_ruby_version_test.rb new file mode 100644 index 0000000000..12503fb481 --- /dev/null +++ b/railties/test/initializer/check_ruby_version_test.rb @@ -0,0 +1,59 @@ +require 'abstract_unit' +require 'active_support/ruby/shim' +require 'initializer' + +RAILS_ROOT.replace File.join(File.dirname(__FILE__), "root") + +module Rails + def self.vendor_rails? ; false ; end +end + +module InitializerTests + class PathsTest < ActiveSupport::TestCase + include ActiveSupport::Testing::Isolation + + test "rails does not initialize with ruby version 1.8.1" do + assert_rails_does_not_boot "1.8.1" + end + + test "rails initializes with ruby version 1.8.2" do + assert_rails_boots "1.8.2" + end + + test "rails does not initialize with ruby version 1.8.3" do + assert_rails_does_not_boot "1.8.3" + end + + test "rails initializes with ruby version 1.8.4" do + assert_rails_boots "1.8.4" + end + + test "rails initializes with ruby version 1.8.5" do + assert_rails_boots "1.8.5" + end + + test "rails initializes with ruby version 1.8.6" do + assert_rails_boots "1.8.6" + end + + def set_ruby_version(version) + $-w = nil + Object.const_set(:RUBY_VERSION, version.freeze) + end + + def assert_rails_boots(version) + set_ruby_version(version) + assert_nothing_raised "It appears that rails does not boot" do + Rails::Initializer.run { |c| c.frameworks = [] } + end + end + + def assert_rails_does_not_boot(version) + set_ruby_version(version) + $stderr = File.open("/dev/null", "w") + assert_raises(SystemExit) do + Rails::Initializer.run { |c| c.frameworks = [] } + end + end + end +end |