aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-09-12 15:22:11 -0500
committerYehuda Katz <wycats@gmail.com>2009-09-12 15:22:11 -0500
commitddb4600ce608b14f9fa07bf1196b78e1d43ad999 (patch)
treec966da55cf5b475cdacb137597dfa1204e6f2547
parenta8a336cbfc55f91dc8befaad2425ff42085a1a4f (diff)
downloadrails-ddb4600ce608b14f9fa07bf1196b78e1d43ad999.tar.gz
rails-ddb4600ce608b14f9fa07bf1196b78e1d43ad999.tar.bz2
rails-ddb4600ce608b14f9fa07bf1196b78e1d43ad999.zip
Get ActionPack's test running on bundled gems. This should make running tests on new machines, as well as CI, work well.
-rw-r--r--.gitignore5
-rw-r--r--actionpack/Gemfile14
-rw-r--r--actionpack/Rakefile12
-rw-r--r--actionpack/test/abstract_unit.rb9
-rw-r--r--actionpack/test/new_base/test_helper.rb5
-rw-r--r--actionpack/vendor/gems/cache/RedCloth-4.2.2.gembin0 -> 224256 bytes
-rw-r--r--actionpack/vendor/gems/cache/mocha-0.9.7.gembin0 -> 59906 bytes
-rw-r--r--actionpack/vendor/gems/cache/rack-1.0.0.gembin0 -> 133632 bytes
-rw-r--r--actionpack/vendor/gems/cache/rack-test-0.4.2.gembin0 -> 17408 bytes
-rw-r--r--actionpack/vendor/gems/cache/rake-0.8.7.gembin0 -> 104960 bytes
-rw-r--r--actionpack/vendor/gems/cache/sqlite3-ruby-1.2.5.gembin0 -> 74240 bytes
-rw-r--r--actionpack/vendor/gems/environment.rb94
12 files changed, 127 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 7a61c37718..e8485acfec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,8 @@ railties/guides/output
*.rbc
*.swp
*.swo
+actionpack/bin
+*/vendor/gems/gems
+*/vendor/gems/specifications
+*/vendor/gems/environment.rb
+*/vendor/gems/dirs/specifications \ No newline at end of file
diff --git a/actionpack/Gemfile b/actionpack/Gemfile
new file mode 100644
index 0000000000..ed1ae2e9c0
--- /dev/null
+++ b/actionpack/Gemfile
@@ -0,0 +1,14 @@
+rails_root = Pathname.new(File.dirname(__FILE__)).join("..")
+
+gem "rack", "~> 1.0.0"
+gem "rack-test", "~> 0.4.2"
+gem "activesupport", "3.0.pre", :vendored_at => rails_root.join("activesupport")
+gem "activemodel", "3.0.pre", :vendored_at => rails_root.join("activemodel")
+
+only :test do
+ gem "mocha"
+ gem "sqlite3-ruby"
+ gem "RedCloth"
+end
+
+disable_system_gems \ No newline at end of file
diff --git a/actionpack/Rakefile b/actionpack/Rakefile
index 06f6905af0..6d98aa3190 100644
--- a/actionpack/Rakefile
+++ b/actionpack/Rakefile
@@ -17,7 +17,17 @@ RUBY_FORGE_PROJECT = "actionpack"
RUBY_FORGE_USER = "webster132"
desc "Default Task"
-task :default => [ :test ]
+task :default => [ :bundle, :test ]
+
+task :bundle do
+ puts "Checking if the bundled testing requirements are up to date..."
+ result = system "gem bundle"
+ unless result
+ puts "The gem bundler is not installed. Installing."
+ system "gem install bundler"
+ system "gem bundle"
+ end
+end
# Run the unit tests
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index a5222fc96d..528180ae32 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -1,20 +1,15 @@
$:.unshift(File.dirname(__FILE__) + '/../lib')
-$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
-$:.unshift(File.dirname(__FILE__) + '/../../activemodel/lib')
$:.unshift(File.dirname(__FILE__) + '/lib')
-
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
$:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers')
+require File.join(File.dirname(__FILE__), "..", "vendor", "gems", "environment")
+
ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp')
ENV['new_base'] = "true"
$stderr.puts "Running old tests on new_base"
-require 'rubygems'
-gem "rack", "~> 1.0.0"
-gem "rack-test", "~> 0.4.2"
-
require 'test/unit'
require 'active_support'
require 'active_support/test_case'
diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb
index 0833e1a11d..5a901ab9d8 100644
--- a/actionpack/test/new_base/test_helper.rb
+++ b/actionpack/test/new_base/test_helper.rb
@@ -1,10 +1,7 @@
$:.unshift(File.dirname(__FILE__) + '/../../lib')
-$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib')
$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'rubygems'
-gem "rack", "~> 1.0.0"
-gem "rack-test", "~> 0.4.2"
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "vendor", "gems", "environment"))
require 'test/unit'
require 'active_support'
diff --git a/actionpack/vendor/gems/cache/RedCloth-4.2.2.gem b/actionpack/vendor/gems/cache/RedCloth-4.2.2.gem
new file mode 100644
index 0000000000..b754b7d113
--- /dev/null
+++ b/actionpack/vendor/gems/cache/RedCloth-4.2.2.gem
Binary files differ
diff --git a/actionpack/vendor/gems/cache/mocha-0.9.7.gem b/actionpack/vendor/gems/cache/mocha-0.9.7.gem
new file mode 100644
index 0000000000..1cbb7253a5
--- /dev/null
+++ b/actionpack/vendor/gems/cache/mocha-0.9.7.gem
Binary files differ
diff --git a/actionpack/vendor/gems/cache/rack-1.0.0.gem b/actionpack/vendor/gems/cache/rack-1.0.0.gem
new file mode 100644
index 0000000000..e20843cf92
--- /dev/null
+++ b/actionpack/vendor/gems/cache/rack-1.0.0.gem
Binary files differ
diff --git a/actionpack/vendor/gems/cache/rack-test-0.4.2.gem b/actionpack/vendor/gems/cache/rack-test-0.4.2.gem
new file mode 100644
index 0000000000..0b82741938
--- /dev/null
+++ b/actionpack/vendor/gems/cache/rack-test-0.4.2.gem
Binary files differ
diff --git a/actionpack/vendor/gems/cache/rake-0.8.7.gem b/actionpack/vendor/gems/cache/rake-0.8.7.gem
new file mode 100644
index 0000000000..0740cec7b0
--- /dev/null
+++ b/actionpack/vendor/gems/cache/rake-0.8.7.gem
Binary files differ
diff --git a/actionpack/vendor/gems/cache/sqlite3-ruby-1.2.5.gem b/actionpack/vendor/gems/cache/sqlite3-ruby-1.2.5.gem
new file mode 100644
index 0000000000..a009b0ba71
--- /dev/null
+++ b/actionpack/vendor/gems/cache/sqlite3-ruby-1.2.5.gem
Binary files differ
diff --git a/actionpack/vendor/gems/environment.rb b/actionpack/vendor/gems/environment.rb
new file mode 100644
index 0000000000..5f7e483c3b
--- /dev/null
+++ b/actionpack/vendor/gems/environment.rb
@@ -0,0 +1,94 @@
+# DO NOT MODIFY THIS FILE
+module Bundler
+ dir = File.dirname(__FILE__)
+
+ ENV["PATH"] = "#{dir}/../../bin:#{ENV["PATH"]}"
+ ENV["RUBYOPT"] = "-r#{__FILE__} #{ENV["RUBYOPT"]}"
+
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/gems/activemodel-3.0.pre/bin")
+ $LOAD_PATH.unshift File.expand_path("#{dir}/../../../activemodel/lib")
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/gems/activesupport-3.0.pre/bin")
+ $LOAD_PATH.unshift File.expand_path("#{dir}/../../../activesupport/lib")
+ $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.0.0/bin")
+ $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.0.0/lib")
+ $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.4.2/bin")
+ $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.4.2/lib")
+
+ @gemfile = "#{dir}/../../Gemfile"
+
+ require "rubygems"
+
+ @bundled_specs = {}
+ @bundled_specs["rack"] = eval(File.read("#{dir}/specifications/rack-1.0.0.gemspec"))
+ @bundled_specs["rack"].loaded_from = "#{dir}/specifications/rack-1.0.0.gemspec"
+ @bundled_specs["activemodel"] = eval(File.read("#{dir}/dirs/specifications/activemodel-3.0.pre.gemspec"))
+ @bundled_specs["activemodel"].loaded_from = "#{dir}/dirs/specifications/activemodel-3.0.pre.gemspec"
+ @bundled_specs["rack-test"] = eval(File.read("#{dir}/specifications/rack-test-0.4.2.gemspec"))
+ @bundled_specs["rack-test"].loaded_from = "#{dir}/specifications/rack-test-0.4.2.gemspec"
+ @bundled_specs["activesupport"] = eval(File.read("#{dir}/dirs/specifications/activesupport-3.0.pre.gemspec"))
+ @bundled_specs["activesupport"].loaded_from = "#{dir}/dirs/specifications/activesupport-3.0.pre.gemspec"
+
+ def self.add_specs_to_loaded_specs
+ Gem.loaded_specs.merge! @bundled_specs
+ end
+
+ def self.add_specs_to_index
+ @bundled_specs.each do |name, spec|
+ Gem.source_index.add_spec spec
+ end
+ end
+
+ add_specs_to_loaded_specs
+ add_specs_to_index
+
+ def self.require_env(env = nil)
+ context = Class.new do
+ def initialize(env) @env = env && env.to_s ; end
+ def method_missing(*) ; end
+ def only(env)
+ old, @only = @only, _combine_onlys(env)
+ yield
+ @only = old
+ end
+ def except(env)
+ old, @except = @except, _combine_excepts(env)
+ yield
+ @except = old
+ end
+ def gem(name, *args)
+ opt = args.last || {}
+ only = _combine_onlys(opt[:only] || opt["only"])
+ except = _combine_excepts(opt[:except] || opt["except"])
+ files = opt[:require_as] || opt["require_as"] || name
+
+ return unless !only || only.any? {|e| e == @env }
+ return if except && except.any? {|e| e == @env }
+
+ files.each { |f| require f }
+ yield if block_given?
+ true
+ end
+ private
+ def _combine_onlys(only)
+ return @only unless only
+ only = [only].flatten.compact.uniq.map { |o| o.to_s }
+ only &= @only if @only
+ only
+ end
+ def _combine_excepts(except)
+ return @except unless except
+ except = [except].flatten.compact.uniq.map { |o| o.to_s }
+ except |= @except if @except
+ except
+ end
+ end
+ context.new(env && env.to_s).instance_eval(File.read(@gemfile))
+ end
+end
+
+module Gem
+ def source_index.refresh!
+ super
+ Bundler.add_specs_to_index
+ end
+end