Permalink
Browse files

support rails 3.2.x with the test suite

  • Loading branch information...
1 parent 00441e0 commit afcd9caab9f14e42c636195e5607b3d1c97d7044 @shime shime committed May 20, 2012
Showing with 29 additions and 11 deletions.
  1. +25 −9 Rakefile
  2. +1 −1 features/step_definitions/rails_application_steps.rb
  3. +3 −1 features/support/rails.rb
View
@@ -115,29 +115,45 @@ task :clobber => [:clobber_rdoc, :clobber_package]
LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
-LOCAL_GEMS = [['sham_rack', nil], ['capistrano', nil], ['sqlite3-ruby', nil], ['sinatra', nil], ['rake', '0.8.7']] +
- RAILS_VERSIONS.collect { |version| ['rails', version] }
+LOCAL_GEMS =
+ [
+ ["rack","1.3.2"],
+ ] +
+ RAILS_VERSIONS.collect { |version| ['rails', version] } +
+ [
+ ['sham_rack', nil],
+ ['capistrano', nil],
+ ['sqlite3-ruby', nil],
+ ["therubyracer",nil]
+ ]
+
desc "Vendor test gems: Run this once to prepare your test environment"
task :vendor_test_gems do
old_gem_path = ENV['GEM_PATH']
old_gem_home = ENV['GEM_HOME']
ENV['GEM_PATH'] = LOCAL_GEM_ROOT
ENV['GEM_HOME'] = LOCAL_GEM_ROOT
+
LOCAL_GEMS.each do |gem_name, version|
gem_file_pattern = [gem_name, version || '*'].compact.join('-')
version_option = version ? "-v #{version}" : ''
pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
existing = Dir.glob(pattern).first
- unless existing
- command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
- puts "Vendoring #{gem_file_pattern}..."
- unless system("#{command} 2>&1")
- puts "Command failed: #{command}"
- exit(1)
- end
+ if existing
+ puts "\nskipping #{gem_name} since it's already vendored," +
+ "remove it from the tmp directory first."
+ next
+ end
+
+ command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
+ puts "Vendoring #{gem_file_pattern}..."
+ unless system("#{command} 2>&1")
+ puts "Command failed: #{command}"
+ exit(1)
end
end
+
ENV['GEM_PATH'] = old_gem_path
ENV['GEM_HOME'] = old_gem_home
end
@@ -15,7 +15,7 @@
load_rails = <<-RUBY
gem 'rails', '#{version_string}'; \
- load Gem.bin_path('rails', 'rails', '#{version_string}')
+ load Gem.bin_path('#{rails_version_at_least("3.2.0") ? "railties" : "rails"}', 'rails', '#{version_string}')
RUBY
@terminal.run(%{ruby -rrubygems -rthread -e "#{load_rails.strip!}" #{rails_create_command} rails_root})
@@ -25,7 +25,9 @@ def rails_uses_rack?
def rails_version
@rails_version ||= begin
- if bundler_manages_gems?
+ if ENV["RAILS_VERSION"]
+ ENV["RAILS_VERSION"]
+ elsif bundler_manages_gems?
rails_version = open(gemfile_path).read.match(/gem.*rails["'].*["'](.+)["']/)[1]
else
environment_file = File.join(rails_root, 'config', 'environment.rb')

0 comments on commit afcd9ca

Please sign in to comment.