multi_rails 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/Manifest.txt +19 -0
- data/README.txt +96 -0
- data/Rakefile +17 -0
- data/init.rb +4 -0
- data/lib/multi_rails.rb +14 -0
- data/lib/multi_rails/config.rb +28 -0
- data/lib/multi_rails/core_extensions.rb +44 -0
- data/lib/multi_rails/loader.rb +50 -0
- data/lib/multi_rails/multi_rails_error.rb +2 -0
- data/lib/multi_rails_init.rb +3 -0
- data/tasks/load_multi_rails_rake_tasks.rb +1 -0
- data/tasks/multi_rails.rake +41 -0
- data/test/config_test.rb +32 -0
- data/test/core_extensions_test.rb +8 -0
- data/test/init_test.rb +28 -0
- data/test/loader_test.rb +80 -0
- data/test/multi_rails_init_test.rb +17 -0
- data/test/multi_rails_test_helper.rb +4 -0
- metadata +80 -0
data/History.txt
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
== 0.0.2 / Tuesday; October 23, 2007
|
2
|
+
|
3
|
+
* first public release!
|
4
|
+
* add link to email group
|
5
|
+
* improve docs
|
6
|
+
* add hook file to load rake tasks when used as a gem
|
7
|
+
* change the env var for specifying the rails version under test to avoid name conflicts
|
8
|
+
|
9
|
+
== 0.0.1 / Sunday; October 21, 2007
|
10
|
+
|
11
|
+
* initial release, no public announcment
|
data/Manifest.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
init.rb
|
6
|
+
lib/multi_rails.rb
|
7
|
+
lib/multi_rails/config.rb
|
8
|
+
lib/multi_rails/core_extensions.rb
|
9
|
+
lib/multi_rails/loader.rb
|
10
|
+
lib/multi_rails/multi_rails_error.rb
|
11
|
+
lib/multi_rails_init.rb
|
12
|
+
tasks/load_multi_rails_rake_tasks.rb
|
13
|
+
tasks/multi_rails.rake
|
14
|
+
test/config_test.rb
|
15
|
+
test/core_extensions_test.rb
|
16
|
+
test/init_test.rb
|
17
|
+
test/loader_test.rb
|
18
|
+
test/multi_rails_init_test.rb
|
19
|
+
test/multi_rails_test_helper.rb
|
data/README.txt
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
MultiRails
|
2
|
+
by Relevance, http://thinkrelevance.com
|
3
|
+
Rob Sanheim - MultiRails lead
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
MultiRails allows easy testing against multiple versions of Rails for your Rails specific gem or plugin.
|
8
|
+
|
9
|
+
Use MultiRails to hook in Rails 2.0 testing in your continuous integration. Still working on Rails 2.0 support?
|
10
|
+
Use MultiRails to see where your test suite falls down against the 2.0 preview releases of Rails.
|
11
|
+
|
12
|
+
MultiRails was initially developed by members of Relevance while developing Streamlined
|
13
|
+
against edge Rails. To see how Streamlined uses MultiRails, go to http://trac.streamlinedframework.org.
|
14
|
+
|
15
|
+
== FEATURES/PROBLEMS:
|
16
|
+
|
17
|
+
* easily test plugins/extensions using a require from your test_helper.rb and a require in your RakeFile
|
18
|
+
* rake tasks to test against a specific version of Rails, or all versions of Rails available locally as Gems
|
19
|
+
|
20
|
+
== TODOs:
|
21
|
+
|
22
|
+
* enable multi_rails testing in a plain ole' Rails app -- this is difficult right now because of the Rails boot process
|
23
|
+
* improve docs on how to override what files are required by multi_rails
|
24
|
+
* test against Rails versions that are just checked out, and not installed via Gems
|
25
|
+
|
26
|
+
== REQUIREMENTS:
|
27
|
+
|
28
|
+
* Ruby 1.8.5 or higher
|
29
|
+
* Rubygems
|
30
|
+
* Rails 1.2.1 or higher
|
31
|
+
* at least one copy of Rails installed via rubygems.
|
32
|
+
|
33
|
+
== INSTALL:
|
34
|
+
|
35
|
+
NOTE - for multi_rails to work at all, you *must* remove any of your own requires of the Rails
|
36
|
+
framework in any sort of test_helper you have. MultiRails handles requiring Rails on its own,
|
37
|
+
immediately after it uses gem to activate the correct version under test.
|
38
|
+
|
39
|
+
* sudo gem install multi_rails
|
40
|
+
|
41
|
+
* in your projects Rakefile, require a simple rb file which just loads the multi_rails rake tasks.
|
42
|
+
|
43
|
+
require 'load_multi_rails_rake_tasks'
|
44
|
+
|
45
|
+
* run rake -T in your root, verify that you see two new rake tasks.
|
46
|
+
|
47
|
+
rake test:multi_rails:all
|
48
|
+
rake test:multi_rails:one
|
49
|
+
|
50
|
+
* In your plugins test_helper, remove any rails specific requires (activerecord, actioncontroller, activesupport, etc),
|
51
|
+
and require multi_rails_init instead.
|
52
|
+
|
53
|
+
require multi_rails_init
|
54
|
+
|
55
|
+
* Run the multi_rails:all rake task to run your test suite against all versions of Rails you have installed via gems. Install
|
56
|
+
other versions of Rails using rubygems to add them to your test suite.
|
57
|
+
|
58
|
+
* For changing the Rails version under test, set the environment variable MULTIRAILS_RAILS_VERSION to version you want, and run
|
59
|
+
the multi_rails:one task or just run a test class directly.
|
60
|
+
|
61
|
+
== HELP
|
62
|
+
|
63
|
+
* Are you trying to use MultiRails in a plain rails application? Right now there isn't a good way to do this, without hacking
|
64
|
+
up your boot.rb. If you have any ideas please do contribute.
|
65
|
+
|
66
|
+
* Getting gem activation errors? Are you sure you removed your rails requires and are just using multi rails?
|
67
|
+
|
68
|
+
* Join the mailing list!
|
69
|
+
http://groups.google.com/group/multi_rails
|
70
|
+
multi_rails@googlegroups.com
|
71
|
+
|
72
|
+
|
73
|
+
== LICENSE:
|
74
|
+
|
75
|
+
(The MIT License)
|
76
|
+
|
77
|
+
Copyright (c) 2007 Relevance, http://thinkrelevance.com
|
78
|
+
|
79
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
80
|
+
a copy of this software and associated documentation files (the
|
81
|
+
'Software'), to deal in the Software without restriction, including
|
82
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
83
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
84
|
+
permit persons to whom the Software is furnished to do so, subject to
|
85
|
+
the following conditions:
|
86
|
+
|
87
|
+
The above copyright notice and this permission notice shall be
|
88
|
+
included in all copies or substantial portions of the Software.
|
89
|
+
|
90
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
91
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
92
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
93
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
94
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
95
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
96
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hoe'
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "/lib/multi_rails"))
|
4
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "/tasks/multi_rails.rake"))
|
5
|
+
|
6
|
+
Hoe.new('multi_rails', MultiRails::VERSION) do |p|
|
7
|
+
p.rubyforge_name = 'multi-rails'
|
8
|
+
p.author = 'Relevance'
|
9
|
+
p.email = 'multi_rails@googlegroups.com'
|
10
|
+
p.summary = 'Testing tool to easily test agaist multiple versions of Rails.'
|
11
|
+
p.description = p.paragraphs_of('README.txt', 0..10).join("\n\n")
|
12
|
+
p.url = 'http://multi-rails.rubyforge.org/'
|
13
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
14
|
+
p.remote_rdoc_dir = '' # Release to root
|
15
|
+
p.test_globs = 'test/**/*_test.rb' # we use the foo_test convention
|
16
|
+
p.spec_extras[:require_paths] = ['lib', 'tasks']
|
17
|
+
end
|
data/init.rb
ADDED
data/lib/multi_rails.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'logger'
|
3
|
+
files = %w(core_extensions config loader multi_rails_error)
|
4
|
+
files.each do |file|
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "multi_rails/#{file}"))
|
6
|
+
end
|
7
|
+
|
8
|
+
module MultiRails
|
9
|
+
VERSION = '0.0.2'
|
10
|
+
|
11
|
+
def self.gem_and_require_rails
|
12
|
+
Loader.gem_and_require_rails
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module MultiRails
|
2
|
+
|
3
|
+
# Simple config object
|
4
|
+
class Config
|
5
|
+
@weird_versions = { "2.0.0.PR" => "1.2.4.7794" }
|
6
|
+
@rails_requires = %w[active_support
|
7
|
+
active_record
|
8
|
+
action_controller
|
9
|
+
action_controller/test_process]
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :weird_versions, :rails_requires
|
13
|
+
def version_lookup(version = nil)
|
14
|
+
return named_version_lookup(version) if version
|
15
|
+
return named_version_lookup(ENV["MULTIRAILS_RAILS_VERSION"]) if ENV['MULTIRAILS_RAILS_VERSION']
|
16
|
+
Loader.latest_stable_version
|
17
|
+
end
|
18
|
+
|
19
|
+
def named_version_lookup(pretty_version)
|
20
|
+
version = @weird_versions[pretty_version] || pretty_version
|
21
|
+
raise MultiRailsError, "Can't find Rails gem version #{pretty_version} - available versions are: #{Loader.all_rails_versions.to_sentence})." if !Loader.all_rails_versions.include? version
|
22
|
+
version
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Add some nice to haves from ActiveSupport
|
2
|
+
|
3
|
+
module Kernel
|
4
|
+
def silence_warnings
|
5
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
6
|
+
yield
|
7
|
+
ensure
|
8
|
+
$VERBOSE = old_verbose
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module HashExtensions
|
13
|
+
def reverse_merge(other_hash)
|
14
|
+
other_hash.merge(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
def reverse_merge!(other_hash)
|
18
|
+
replace(reverse_merge(other_hash))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module ArrayExtensions
|
23
|
+
# Converts the array to comma-seperated sentence where the last element is joined by the connector word. Options:
|
24
|
+
# * <tt>:connector</tt>: The word used to join the last element in arrays with two or more elements (default: "and")
|
25
|
+
# * <tt>:skip_last_comma</tt>: Set to true to return "a, b and c" instead of "a, b, and c".
|
26
|
+
def to_sentence(options = {})
|
27
|
+
options.reverse_merge! :connector => 'and', :skip_last_comma => false
|
28
|
+
|
29
|
+
case length
|
30
|
+
when 0
|
31
|
+
""
|
32
|
+
when 1
|
33
|
+
self[0]
|
34
|
+
when 2
|
35
|
+
"#{self[0]} #{options[:connector]} #{self[1]}"
|
36
|
+
else
|
37
|
+
"#{self[0...-1].join(', ')}#{options[:skip_last_comma] ? '' : ','} #{options[:connector]} #{self[-1]}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
Array.send(:include, ArrayExtensions) unless Array.respond_to?(:to_sentence)
|
44
|
+
Hash.send(:include, HashExtensions) unless Hash.respond_to?(:reverse_merge) && Hash.respond_to?(:reverse_merge!)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module MultiRails
|
2
|
+
|
3
|
+
class Loader
|
4
|
+
attr_reader :version
|
5
|
+
|
6
|
+
def self.logger
|
7
|
+
@logger ||= Logger.new(STDOUT)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Require and gem rails
|
11
|
+
# Will use a default version if none is supplied
|
12
|
+
def self.gem_and_require_rails(rails_version = nil)
|
13
|
+
rails_version = MultiRails::Config.version_lookup(rails_version)
|
14
|
+
Loader.new(rails_version).gem_and_require_rails
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns a list of all Rails versions available, oldest first
|
18
|
+
def self.all_rails_versions
|
19
|
+
specs = Gem::cache.find_name("rails")
|
20
|
+
specs.map {|spec| spec.version.to_s }.sort
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.latest_stable_version
|
24
|
+
all_rails_versions.sort.reverse.detect {|version| version.count(".") < 3 }
|
25
|
+
end
|
26
|
+
|
27
|
+
# A version of the loader is created to gem and require one version of Rails
|
28
|
+
def initialize(version)
|
29
|
+
@version = version
|
30
|
+
end
|
31
|
+
|
32
|
+
# Gem a version of Rails, and require appropriate files
|
33
|
+
def gem_and_require_rails
|
34
|
+
gem_rails
|
35
|
+
require_rails
|
36
|
+
end
|
37
|
+
|
38
|
+
def gem_rails
|
39
|
+
gem 'rails', version
|
40
|
+
rescue LoadError => e
|
41
|
+
msg = %Q[Cannot find gem for Rails version: '#{version}'!\nInstall the missing gem with:\nsudo gem install -v=#{version} rails]
|
42
|
+
raise MultiRailsError, msg
|
43
|
+
end
|
44
|
+
|
45
|
+
def require_rails
|
46
|
+
Config.rails_requires.each {|lib| require lib }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "multi_rails.rake"))
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "/../lib/multi_rails"))
|
5
|
+
|
6
|
+
# Enable overriding the already invoked flag of a Rake task
|
7
|
+
class Rake::Task
|
8
|
+
attr_accessor :already_invoked
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :test do
|
12
|
+
namespace :multi_rails do
|
13
|
+
|
14
|
+
desc "Run against all versions of rubygem installed versions of Rails"
|
15
|
+
task :all do
|
16
|
+
MultiRails::Loader.all_rails_versions.each_with_index do |version, index|
|
17
|
+
silence_warnings { ENV["MULTIRAILS_RAILS_VERSION"] = version }
|
18
|
+
print_rails_version
|
19
|
+
reset_rake_task unless index == 0
|
20
|
+
Rake::Task[:test].invoke
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Run against one verison of Rails specified as 'MULTIRAILS_RAILS_VERSION' - for example 'rake test:multi_rails:one MULTIRAILS_RAILS_VERSION=1.2.3'"
|
25
|
+
task :one do
|
26
|
+
print_rails_version
|
27
|
+
Rake::Task[:test].invoke
|
28
|
+
end
|
29
|
+
|
30
|
+
BAR = "=" * 80
|
31
|
+
def print_rails_version
|
32
|
+
puts "\n#{BAR}\nRequiring rails version: #{MultiRails::Config.version_lookup}\n#{BAR}"
|
33
|
+
end
|
34
|
+
|
35
|
+
# Need to hack the Rake test task a bit, otherwise it will only run once and never repeat.
|
36
|
+
def reset_rake_task
|
37
|
+
Rake::Task[:test].already_invoked = false
|
38
|
+
Rake::Task[:test].prerequisites.each {|p| Rake::Task[p].already_invoked = false}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/test/config_test.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "multi_rails_test_helper"))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails"))
|
3
|
+
|
4
|
+
describe "Version Lookup in config" do
|
5
|
+
|
6
|
+
it "should use argument version if passed in " do
|
7
|
+
MultiRails::Config.version_lookup("1.2.3").should == "1.2.3"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should use env var if set" do
|
11
|
+
begin
|
12
|
+
MultiRails::Loader.stubs(:all_rails_versions).returns(["1.2.99"])
|
13
|
+
ENV["MULTIRAILS_RAILS_VERSION"] = "1.2.99"
|
14
|
+
MultiRails::Config.version_lookup.should == "1.2.99"
|
15
|
+
ensure
|
16
|
+
silence_warnings { ENV["MULTIRAILS_RAILS_VERSION"] = nil }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise if providing env var and we dont find a corresponding version" do
|
21
|
+
begin
|
22
|
+
ENV["MULTIRAILS_RAILS_VERSION"] = "X.X.99"
|
23
|
+
lambda { MultiRails::Config.version_lookup }.should.raise(MultiRailsError)
|
24
|
+
ensure
|
25
|
+
silence_warnings { ENV["MULTIRAILS_RAILS_VERSION"] = nil }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should use latest stable version if there is no argumnt or env var" do
|
30
|
+
MultiRails::Config.version_lookup.should == MultiRails::Loader.latest_stable_version
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "multi_rails_test_helper"))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails"))
|
3
|
+
|
4
|
+
describe "core extensions" do
|
5
|
+
it "should extend Kernel" do
|
6
|
+
Kernel.should.respond_to? :silence_warnings
|
7
|
+
end
|
8
|
+
end
|
data/test/init_test.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "multi_rails_test_helper"))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails"))
|
3
|
+
|
4
|
+
describe "Rails plugin init" do
|
5
|
+
it "should do nothing if RAILS_ENV isn't set" do
|
6
|
+
MultiRails.expects(:gem_and_require_rails).never
|
7
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "../init.rb"))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should only do anything in Test environment" do
|
11
|
+
MultiRails.expects(:gem_and_require_rails).never
|
12
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "../init.rb"))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should require rails in Test environment" do
|
16
|
+
silence_warnings do
|
17
|
+
begin
|
18
|
+
orig_rails_env = Object.const_defined?("RAILS_ENV") ? Object.const_get("RAILS_ENV") : nil
|
19
|
+
Object.const_set("RAILS_ENV", "test")
|
20
|
+
MultiRails.expects(:gem_and_require_rails).once
|
21
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "../init.rb"))
|
22
|
+
ensure
|
23
|
+
Object.const_set("RAILS_ENV", orig_rails_env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/test/loader_test.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "multi_rails_test_helper"))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails"))
|
3
|
+
|
4
|
+
describe "loader" do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
never_really_require_rails
|
8
|
+
never_puts
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should fall back to a default verison to try" do
|
12
|
+
stub_rails_requires
|
13
|
+
MultiRails::Loader.any_instance.expects(:gem).with("rails", MultiRails::Loader.latest_stable_version)
|
14
|
+
MultiRails::Loader.gem_and_require_rails
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should fail fast if we are missing a requested gem version" do
|
18
|
+
lambda { MultiRails::Loader.gem_and_require_rails("9.9.9") }.should.raise(MultiRailsError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should gem the specified version" do
|
22
|
+
stub_rails_requires
|
23
|
+
MultiRails::Loader.any_instance.expects(:gem).with("rails", "1.2.5").returns(true)
|
24
|
+
MultiRails::Loader.gem_and_require_rails("1.2.5")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should allow using a better name for weird gem version numbers, like 2.0.0 PR => 1.2.4.7794" do
|
28
|
+
stub_rails_requires
|
29
|
+
MultiRails::Loader.any_instance.expects(:gem).with("rails", MultiRails::Config.weird_versions["2.0.0.PR"]).returns(true)
|
30
|
+
MultiRails::Loader.gem_and_require_rails("2.0.0.PR")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should require the needed dependancies" do
|
34
|
+
MultiRails::Loader.any_instance.stubs(:gem)
|
35
|
+
MultiRails::Config.rails_requires.each do |file|
|
36
|
+
MultiRails::Loader.any_instance.expects(:require).with(file)
|
37
|
+
end
|
38
|
+
MultiRails::Loader.gem_and_require_rails
|
39
|
+
end
|
40
|
+
|
41
|
+
def stub_rails_requires
|
42
|
+
MultiRails::Loader.any_instance.stubs(:require).returns(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def never_really_require_rails
|
46
|
+
MultiRails::Loader.any_instance.expects(:require).never
|
47
|
+
end
|
48
|
+
|
49
|
+
def never_puts
|
50
|
+
MultiRails::Loader.stubs(:puts)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "finding all gems of rails available" do
|
55
|
+
|
56
|
+
it "should find rails by name when retrieving all rails versions, in order to avoid false positives with other gems with rails in the name" do
|
57
|
+
Gem::cache.expects(:find_name).with("rails").returns([])
|
58
|
+
MultiRails::Loader.all_rails_versions
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return all Rails versions it finds sorted with the earliest versions first" do
|
62
|
+
specs = [stub(:version => stub(:to_s => "1.2.4")), stub(:version => stub(:to_s => "1.2.3"))]
|
63
|
+
Gem::cache.expects(:find_name).with("rails").returns(specs)
|
64
|
+
MultiRails::Loader.all_rails_versions.should == ["1.2.3", "1.2.4"]
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "finding latest stable version" do
|
70
|
+
it "should find the latest stable rails gem" do
|
71
|
+
MultiRails::Loader.stubs(:all_rails_versions).returns(["1.2.3", "1.2.5", "1.2.5.1343"])
|
72
|
+
MultiRails::Loader.latest_stable_version.should == "1.2.5"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should find 2.0.0 when its released" do
|
76
|
+
MultiRails::Loader.stubs(:all_rails_versions).returns(["1.2.3", "1.2.5", "1.2.5.1343", "2.0.0", "1.2.7"])
|
77
|
+
MultiRails::Loader.latest_stable_version.should == "2.0.0"
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "multi_rails_test_helper"))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails"))
|
3
|
+
|
4
|
+
describe "Rubygem test helper init" do
|
5
|
+
it "should call gem and require rails" do
|
6
|
+
MultiRails.expects(:gem_and_require_rails).once
|
7
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails_init.rb"))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should actually do the gem and require" do
|
11
|
+
MultiRails::Loader.any_instance.expects(:require).never
|
12
|
+
MultiRails::Loader.any_instance.expects(:gem_rails)
|
13
|
+
MultiRails::Loader.any_instance.expects(:require_rails)
|
14
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails_init.rb"))
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: multi_rails
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.2
|
7
|
+
date: 2007-10-23 00:00:00 -04:00
|
8
|
+
summary: Testing tool to easily test agaist multiple versions of Rails.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
- tasks
|
12
|
+
email: multi_rails@googlegroups.com
|
13
|
+
homepage: http://multi-rails.rubyforge.org/
|
14
|
+
rubyforge_project: multi-rails
|
15
|
+
description: "MultiRails by Relevance, http://thinkrelevance.com Rob Sanheim - MultiRails lead == DESCRIPTION: MultiRails allows easy testing against multiple versions of Rails for your Rails specific gem or plugin. Use MultiRails to hook in Rails 2.0 testing in your continuous integration. Still working on Rails 2.0 support? Use MultiRails to see where your test suite falls down against the 2.0 preview releases of Rails. MultiRails was initially developed by members of Relevance while developing Streamlined against edge Rails. To see how Streamlined uses MultiRails, go to http://trac.streamlinedframework.org. == FEATURES/PROBLEMS: * easily test plugins/extensions using a require from your test_helper.rb and a require in your RakeFile * rake tasks to test against a specific version of Rails, or all versions of Rails available locally as Gems == TODOs: * enable multi_rails testing in a plain ole' Rails app -- this is difficult right now because of the Rails boot process * improve docs on how to override what files are required by multi_rails * test against Rails versions that are just checked out, and not installed via Gems == REQUIREMENTS: * Ruby 1.8.5 or higher * Rubygems * Rails 1.2.1 or higher * at least one copy of Rails installed via rubygems. == INSTALL:"
|
16
|
+
autorequire:
|
17
|
+
default_executable:
|
18
|
+
bindir: bin
|
19
|
+
has_rdoc: true
|
20
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
signing_key:
|
28
|
+
cert_chain:
|
29
|
+
post_install_message:
|
30
|
+
authors:
|
31
|
+
- Relevance
|
32
|
+
files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
- Rakefile
|
37
|
+
- init.rb
|
38
|
+
- lib/multi_rails.rb
|
39
|
+
- lib/multi_rails/config.rb
|
40
|
+
- lib/multi_rails/core_extensions.rb
|
41
|
+
- lib/multi_rails/loader.rb
|
42
|
+
- lib/multi_rails/multi_rails_error.rb
|
43
|
+
- lib/multi_rails_init.rb
|
44
|
+
- tasks/load_multi_rails_rake_tasks.rb
|
45
|
+
- tasks/multi_rails.rake
|
46
|
+
- test/config_test.rb
|
47
|
+
- test/core_extensions_test.rb
|
48
|
+
- test/init_test.rb
|
49
|
+
- test/loader_test.rb
|
50
|
+
- test/multi_rails_init_test.rb
|
51
|
+
- test/multi_rails_test_helper.rb
|
52
|
+
test_files:
|
53
|
+
- test/config_test.rb
|
54
|
+
- test/core_extensions_test.rb
|
55
|
+
- test/init_test.rb
|
56
|
+
- test/loader_test.rb
|
57
|
+
- test/multi_rails_init_test.rb
|
58
|
+
rdoc_options:
|
59
|
+
- --main
|
60
|
+
- README.txt
|
61
|
+
extra_rdoc_files:
|
62
|
+
- History.txt
|
63
|
+
- Manifest.txt
|
64
|
+
- README.txt
|
65
|
+
executables: []
|
66
|
+
|
67
|
+
extensions: []
|
68
|
+
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
dependencies:
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: hoe
|
74
|
+
version_requirement:
|
75
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.3.0
|
80
|
+
version:
|