multi_rails 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ require 'autotest'
2
+ $LOAD_PATH.unshift "test", "test/autotest"
3
+ # Make sure autotest groks our directory structure to map tests to files
4
+ Autotest.add_discovery do
5
+ ["railsplugin"]
6
+ end
@@ -1,3 +1,11 @@
1
+ == 0.0.4
2
+
3
+ * Change the all task so that the build will run through all rails versions, even if one of them fails, but at the end
4
+ the failing versions are printed and we abort. Thanks to Evan Weaver for initial patch and idea.
5
+ * display the rails gem from the load path as a sanity check right after we gem/require
6
+ * add autotest railsplugin discovery, so I can use autotest to test multi_rails
7
+ * various rake tweaks to make release easier and more automated
8
+
1
9
  == 0.0.3
2
10
 
3
11
  * add support for using multi_rails with regular Rails apps, which was way more work then it should have been.
@@ -17,4 +25,4 @@
17
25
 
18
26
  == 0.0.1 / Sunday; October 21, 2007
19
27
 
20
- * initial release, no public announcment
28
+ * initial release, no public announcement
@@ -1,9 +1,12 @@
1
+ .autotest
1
2
  History.txt
2
3
  MIT-LICENSE
3
4
  Manifest.txt
4
5
  README.txt
5
6
  Rakefile
7
+ autotest.rb
6
8
  bin/multi_rails_runner.rb
9
+ credits.txt
7
10
  install.rb
8
11
  lib/multi_rails.rb
9
12
  lib/multi_rails/config.rb
@@ -14,6 +17,7 @@ lib/multi_rails/rails_app_helper.rb
14
17
  lib/multi_rails_init.rb
15
18
  tasks/load_multi_rails_rake_tasks.rb
16
19
  tasks/multi_rails.rake
20
+ test/autotest/railsplugin.rb
17
21
  test/config_test.rb
18
22
  test/core_extensions_test.rb
19
23
  test/install_test.rb
data/README.txt CHANGED
@@ -1,48 +1,42 @@
1
- MultiRails
1
+ #### MultiRails
2
2
  by Relevance, http://thinkrelevance.com
3
3
  Rob Sanheim - MultiRails lead
4
4
 
5
- == URLs:
5
+ MultiRails lets you test your Rails plugin or app against many versions of Rails in one sweep.
6
6
 
7
- rubyforge: http://rubyforge.org/projects/multi-rails/
8
- svn stable: http://robsanheim.googlecode.com/svn/tags/stable/multi_rails
9
- svn trunk: http://robsanheim.googlecode.com/svn/trunk/multi_rails
10
- mailing list: http://groups.google.com/group/multi_rails
7
+ #### DESCRIPTION:
11
8
 
12
- == DESCRIPTION:
13
-
14
- MultiRails allows easy testing against multiple versions of Rails for your Rails specific gem or plugin. IT also has tentative support testing Rails applications against multiple versions of Rails.
9
+ MultiRails allows easy testing against multiple versions of Rails for your Rails specific gem or plugin. It also has tentative support testing Rails applications against multiple versions of Rails.
15
10
 
16
11
  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.
17
12
 
18
- MultiRails was initially developed by members of Relevance while developing Streamlined
19
- against edge Rails. To see how Streamlined uses MultiRails, go to http://trac.streamlinedframework.org.
13
+ 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.
20
14
 
21
- == FEATURES:
15
+ #### FEATURES:
22
16
 
23
17
  * easily test plugins/extensions using a require from your test_helper.rb and a require in your RakeFile
24
18
  * rake tasks to test against a specified version of Rails, the latest version, or all versions
25
19
  * tentative support for testing plain Rails apps against multiple versions of Rails
26
20
  * Uses rubygems for version management of Rails
27
21
 
28
- == TODOs:
22
+ #### TODOs:
29
23
 
30
24
  * improve docs on how to override what files are required by multi_rails
31
25
  * maybe add ability to load plain Rails versions -- ie checked out copies not in RubyGems
32
26
 
33
- == NOTES:
27
+ #### NOTES:
34
28
 
35
29
  * (__For Rails apps only__) multi_rails will rename your vendor/rails directory to vendor/rails.off if it finds one within your rails app. We have to do this to make Rails fall back to RubyGems rails. Multi_rails will rename back to the correct vendor/rails when done testing, so it will not interrupt your app in normal use.
36
30
  * (__For Rails apps only__) multi_rails needs to add a line to top of your environment.rb to hook into -- see the instructions below for more details
37
31
 
38
- == REQUIREMENTS:
32
+ #### REQUIREMENTS:
39
33
 
40
34
  * Ruby 1.8.5 or higher
41
35
  * Rubygems
42
36
  * Rails 1.2.1 or higher
43
37
  * at least one copy of Rails installed via rubygems.
44
38
 
45
- == INSTALLING FOR RAILS APPS
39
+ #### INSTALLING FOR RAILS APPS
46
40
 
47
41
  * install the plugin, which will copy the multi_rails_runner into your script folder on install.
48
42
  script/plugin install http://robsanheim.googlecode.com/svn/tags/stable/multi_rails
@@ -57,7 +51,7 @@ against edge Rails. To see how Streamlined uses MultiRails, go to http://trac.s
57
51
  or just a specific version:
58
52
  MULTIRAILS_RAILS_VERSION=1.2.5 script/multi_rails_runner one
59
53
 
60
- == INSTALLING FOR PLUGINS
54
+ #### INSTALLING FOR PLUGINS
61
55
 
62
56
  * Install multi_rails
63
57
  sudo gem install multi_rails
@@ -78,16 +72,23 @@ against edge Rails. To see how Streamlined uses MultiRails, go to http://trac.s
78
72
 
79
73
  * For changing the Rails version under test, set the environment variable MULTIRAILS_RAILS_VERSION to version you want, and run the multi_rails:one task or just run a test class directly.
80
74
 
81
- == HELP
75
+ #### HELP
82
76
 
83
- * Join the mailing list!
84
- http://groups.google.com/group/multi_rails
85
- multi_rails@googlegroups.com
77
+ * Join the mailing list! - http://groups.google.com/group/multi_rails
86
78
 
87
79
  * Rails plugin testing is pretty solid, but rails *app* testing is still new. Post issues to the mailing list.
88
80
  * Getting gem activation errors? Post to the list with how you are using multi_rails, and I'll try to help.
89
81
 
90
- == LICENSE:
82
+ #### URLs
83
+
84
+ * rubyforge home - http://rubyforge.org/projects/multi-rails/
85
+ * rdocs - http://multi-rails.rubyforge.org/
86
+ * mailing list - http://groups.google.com/group/multi_rails
87
+
88
+ * svn stable - http://robsanheim.googlecode.com/svn/tags/stable/multi_rails (gem is released from here)
89
+ * svn trunk - http://robsanheim.googlecode.com/svn/trunk/multi_rails
90
+
91
+ #### LICENSE:
91
92
 
92
93
  (The MIT License)
93
94
 
data/Rakefile CHANGED
@@ -22,4 +22,35 @@ task :copy_stable do
22
22
  stable_dir = "~/src/opensource/robsanheim/tags/stable/multi_rails/"
23
23
  puts %x[rsync --exclude='.svn' -r #{trunk_dir} #{stable_dir}]
24
24
  puts %x[svn ci #{stable_dir} -m 'Release to stable from trunk.']
25
+ end
26
+
27
+ desc "Convert the readme from markdown to html to prep for posting on blog/email/whatever."
28
+ task :email_to_html => :email do
29
+ require 'redcloth'
30
+ RedCloth::DEFAULT_RULES.replace [:markdown, :textile]
31
+
32
+ email = File.read("email.txt")
33
+ html = RedCloth.new(email).to_html
34
+ html = text_helper.auto_link(html)
35
+ File.open("email.html", "w") do |f|
36
+ f << html
37
+ end
38
+ end
39
+
40
+ desc "Do a full release of the multi_rails, including copying to stable tag, pushing docs and prepping for blog/annoucement."
41
+ task :full_release => [:require_version, :copy_stable, :publish_docs, :email_to_html, :release]
42
+
43
+ desc "Must supply the VERSION env var"
44
+ task :require_version do
45
+ raise "You must supply a VERSION=x.x.x environment var to release!" unless ENV["VERSION"]
46
+ end
47
+
48
+ # it should be easier then this to do some g'd autolinking
49
+ def text_helper
50
+ gem 'actionpack'
51
+ require 'action_controller' # bringing this in for autolinks
52
+ helper = Object.new
53
+ helper.extend ActionView::Helpers::TextHelper
54
+ helper.extend ActionView::Helpers::TagHelper
55
+ helper
25
56
  end
@@ -0,0 +1,6 @@
1
+ require 'autotest'
2
+ $LOAD_PATH.unshift "test", "test/autotest"
3
+ # Make sure autotest groks our directory structure to map tests to files
4
+ Autotest.add_discovery do
5
+ ["railsplugin"]
6
+ end
@@ -0,0 +1,3 @@
1
+ Thanks to:
2
+
3
+ Evan Weaver
@@ -6,7 +6,8 @@ files.each do |file|
6
6
  end
7
7
 
8
8
  module MultiRails
9
- VERSION = '0.0.3'
9
+ VERSION = '0.0.4'
10
+ BAR = "=" * 80 # BEST CONSTANT EVAH
10
11
 
11
12
  def self.gem_and_require_rails
12
13
  Loader.gem_and_require_rails
@@ -22,6 +22,16 @@ module MultiRails
22
22
  version
23
23
  end
24
24
 
25
+ # Output rails from the load path as a sanity check, to make sure we are really using the version of Rails we think we are
26
+ def rails_load_path
27
+ gem_rails_regex = %r[gems/(rails-[\d\.]+)/]
28
+ load_path.grep(gem_rails_regex).first.match(gem_rails_regex)[1] rescue nil
29
+ end
30
+
31
+ def load_path
32
+ $LOAD_PATH
33
+ end
34
+
25
35
  end
26
36
  end
27
37
 
@@ -20,10 +20,13 @@ module MultiRails
20
20
  specs.map {|spec| spec.version.to_s }.sort
21
21
  end
22
22
 
23
+ # Try to detech the latest stable by finding the most recent version with less then 4 version parts
24
+ # -- not sure if there is a better way?
23
25
  def self.latest_stable_version
24
26
  all_rails_versions.sort.reverse.detect {|version| version.count(".") < 3 }
25
27
  end
26
28
 
29
+ # Find the most recent version
27
30
  def self.latest_version
28
31
  all_rails_versions.sort.last
29
32
  end
@@ -37,6 +40,12 @@ module MultiRails
37
40
  def gem_and_require_rails
38
41
  gem_rails
39
42
  require_rails
43
+ display_rails_gem_used
44
+ end
45
+
46
+ # Display the rails gem from the laod path, as a sanity check to make sure we are getting the rails version we expect
47
+ def display_rails_gem_used
48
+ puts %[#{MultiRails::BAR}\nUsing rails gem: #{Config.rails_load_path}\n]
40
49
  end
41
50
 
42
51
  def gem_rails
@@ -14,13 +14,20 @@ namespace :test do
14
14
  desc "Run against all installed versions of Rails. Local versions found: [#{MultiRails::Loader.all_rails_versions.to_sentence}]."
15
15
  task :all do
16
16
  begin
17
+ failed_versions = []
17
18
  MultiRails::Loader.all_rails_versions.each_with_index do |version, index|
18
19
  silence_warnings { ENV["MULTIRAILS_RAILS_VERSION"] = version }
19
20
  init_for_rails_app(version) if within_rails_app?
20
21
  print_rails_version
21
22
  reset_test_tasks unless index == 0
22
- Rake::Task[:test].invoke
23
+ begin
24
+ Rake::Task[:test].invoke
25
+ rescue RuntimeError => e
26
+ puts e.message
27
+ failed_versions << version
28
+ end
23
29
  end
30
+ abort("Build failed with Rails versions: [#{failed_versions.to_sentence}].") if failed_versions.any?
24
31
  ensure
25
32
  clean_up
26
33
  end
@@ -66,9 +73,8 @@ namespace :test do
66
73
  MultiRails::RailsAppHelper.clean_up if within_rails_app?
67
74
  end
68
75
 
69
- BAR = "=" * 80
70
76
  def print_rails_version
71
- puts "\n#{BAR}\nRequiring rails version: #{MultiRails::Config.version_lookup}\n#{BAR}"
77
+ puts "\n#{MultiRails::BAR}\nTesting with Rails #{MultiRails::Config.version_lookup}\n#{MultiRails::BAR}"
72
78
  end
73
79
 
74
80
  # Need to hack the Rake test task a bit, otherwise it will only run once and never repeat.
@@ -0,0 +1,35 @@
1
+ # Discover our lib and tests for autotest'ing Rails Plugins
2
+ class Autotest::Railsplugin < Autotest
3
+ def initialize
4
+ super
5
+ @exceptions = /\/\./
6
+ @test_mappings = {
7
+ /^lib\/(.*)\.rb$/ => proc { |filename, m|
8
+ # p "match #{m[1]}"
9
+ file = File.basename(filename).gsub("_", "_?").gsub(".rb", "")
10
+ foo = files_matching %r%^test/.*#{file}_test.rb$%
11
+ # p "the file: #{file}"
12
+ # p "the regex: #{files_matching %r%^test/.*#{file}_test.rb$%}"
13
+ # p "files_matching: #{foo}"
14
+ foo
15
+ },
16
+ /^test\/.*_test\.rb$/ => proc { |filename, _|
17
+ filename
18
+ }
19
+ }
20
+ end
21
+
22
+ def files_matching regexp
23
+ # puts @files.sort.inspect
24
+ @files.keys.select { |k|
25
+ k =~ regexp
26
+ }
27
+ end
28
+
29
+ # def files_matching regexp
30
+ # @files.keys.select { |k|
31
+ # k =~ regexp
32
+ # }
33
+ # end
34
+
35
+ end
@@ -30,3 +30,25 @@ describe "Version Lookup in config" do
30
30
  MultiRails::Config.version_lookup.should == MultiRails::Loader.latest_stable_version
31
31
  end
32
32
  end
33
+
34
+ describe "getting the rails load path " do
35
+ it "should grab only the real rails paths, and ignore false rails directories in the load path" do
36
+ load_path = ["/Users/rsanheim/src/relevance/essi/trunk/essi/vendor/plugins/test_spec_on_rails/lib",
37
+ "/Users/rsanheim/src/relevance/essi/trunk/essi/vendor/plugins/rails_env/lib",
38
+ "/opt/local/lib/ruby/gems/1.8/gems/rails-2.0.1/lib/../builtin/rails_info/", "/opt/local/lib/ruby/gems/1.8/gems/rails-2.0.1/lib",
39
+ "/opt/local/lib/ruby/gems/1.8/gems/rails-2.0.1/bin", "/Users/rsanheim/src/project/trunk/foo/vendor/gems/rails_env-0.4.0/lib"]
40
+ MultiRails::Config.stubs(:load_path).returns(load_path)
41
+ MultiRails::Config.rails_load_path.should == "rails-2.0.1"
42
+ end
43
+
44
+ it "should use the real load path" do
45
+ MultiRails::Config.load_path.should == $LOAD_PATH
46
+ end
47
+
48
+ it "should return nil if we can't figure out the rails version" do
49
+ load_path = ["/Users/rsanheim/src/relevance/essi/trunk/essi/vendor/plugins/test_spec_on_rails/lib",
50
+ "/Users/rsanheim/src/relevance/essi/trunk/essi/vendor/plugins/rails_env/lib"]
51
+ MultiRails::Config.stubs(:load_path).returns(load_path)
52
+ MultiRails::Config.rails_load_path.should == nil
53
+ end
54
+ end
@@ -7,7 +7,8 @@ describe "loader" do
7
7
  never_puts
8
8
  end
9
9
 
10
- it "should fall back to a default verison to try" do
10
+ it "should fall back to a default version to try" do
11
+ MultiRails::Loader.any_instance.stubs(:display_rails_gem_used)
11
12
  stub_rails_requires
12
13
  MultiRails::Loader.any_instance.expects(:gem).with("rails", MultiRails::Loader.latest_stable_version)
13
14
  MultiRails::Loader.gem_and_require_rails
@@ -18,12 +19,14 @@ describe "loader" do
18
19
  end
19
20
 
20
21
  it "should gem the specified version" do
22
+ MultiRails::Loader.any_instance.stubs(:display_rails_gem_used)
21
23
  stub_rails_requires
22
24
  MultiRails::Loader.any_instance.expects(:gem).with("rails", "1.2.5").returns(true)
23
25
  MultiRails::Loader.gem_and_require_rails("1.2.5")
24
26
  end
25
27
 
26
28
  it "should allow using a better name for weird gem version numbers, like 2.0.0 PR => 1.2.4.7794" do
29
+ MultiRails::Loader.any_instance.stubs(:display_rails_gem_used)
27
30
  MultiRails::Loader.stubs(:all_rails_versions).returns(["1.2.3", "1.2.4", "1.2.4.7794"])
28
31
  stub_rails_requires
29
32
  MultiRails::Loader.any_instance.expects(:gem).with("rails", MultiRails::Config.weird_versions["2.0.0.PR"]).returns(true)
@@ -31,6 +34,7 @@ describe "loader" do
31
34
  end
32
35
 
33
36
  it "should require the needed dependancies" do
37
+ MultiRails::Loader.any_instance.stubs(:display_rails_gem_used)
34
38
  MultiRails::Loader.any_instance.stubs(:gem)
35
39
  MultiRails::Config.rails_requires.each do |file|
36
40
  MultiRails::Loader.any_instance.expects(:require).with(file)
@@ -46,9 +50,6 @@ describe "loader" do
46
50
  MultiRails::Loader.any_instance.expects(:require).never
47
51
  end
48
52
 
49
- def never_puts
50
- MultiRails::Loader.stubs(:puts)
51
- end
52
53
  end
53
54
 
54
55
  describe "finding all gems of rails available" do
@@ -1,6 +1,8 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "multi_rails_test_helper"))
2
2
 
3
3
  describe "Rubygem test helper init" do
4
+ setup { never_puts }
5
+
4
6
  it "should call gem and require rails" do
5
7
  MultiRails.expects(:gem_and_require_rails).once
6
8
  load File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails_init.rb"))
@@ -3,4 +3,11 @@ require 'test/spec'
3
3
  require 'mocha'
4
4
  require 'redgreen' unless Object.const_defined?("TextMate")
5
5
 
6
- require File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails"))
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/multi_rails"))
7
+
8
+ class Test::Unit::TestCase
9
+ def never_puts
10
+ MultiRails::Loader.stubs(:puts)
11
+ MultiRails::Loader.any_instance.stubs(:puts)
12
+ end
13
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: multi_rails
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.3
7
- date: 2007-12-06 00:00:00 -05:00
6
+ version: 0.0.4
7
+ date: 2007-12-15 00:00:00 -05:00
8
8
  summary: Testing tool to easily test agaist multiple versions of Rails.
9
9
  require_paths:
10
10
  - lib
@@ -12,7 +12,7 @@ require_paths:
12
12
  email: multi_rails@googlegroups.com
13
13
  homepage: http://multi-rails.rubyforge.org/
14
14
  rubyforge_project: multi-rails
15
- description: "MultiRails by Relevance, http://thinkrelevance.com Rob Sanheim - MultiRails lead == URLs: rubyforge: http://rubyforge.org/projects/multi-rails/ svn stable: http://robsanheim.googlecode.com/svn/tags/stable/multi_rails svn trunk: http://robsanheim.googlecode.com/svn/trunk/multi_rails mailing list: http://groups.google.com/group/multi_rails == DESCRIPTION: MultiRails allows easy testing against multiple versions of Rails for your Rails specific gem or plugin. IT also has tentative support testing Rails applications against multiple versions of Rails. 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: * easily test plugins/extensions using a require from your test_helper.rb and a require in your RakeFile * rake tasks to test against a specified version of Rails, the latest version, or all versions * tentative support for testing plain Rails apps against multiple versions of Rails * Uses rubygems for version management of Rails == TODOs: * improve docs on how to override what files are required by multi_rails * maybe add ability to load plain Rails versions -- ie checked out copies not in RubyGems == NOTES: * (__For Rails apps only__) multi_rails will rename your vendor/rails directory to vendor/rails.off if it finds one within your rails app. We have to do this to make Rails fall back to RubyGems rails. Multi_rails will rename back to the correct vendor/rails when done testing, so it will not interrupt your app in normal use. * (__For Rails apps only__) multi_rails needs to add a line to top of your environment.rb to hook into -- see the instructions below for more details"
15
+ description: "#### MultiRails by Relevance, http://thinkrelevance.com Rob Sanheim - MultiRails lead MultiRails lets you test your Rails plugin or app against many versions of Rails in one sweep. #### DESCRIPTION: MultiRails allows easy testing against multiple versions of Rails for your Rails specific gem or plugin. It also has tentative support testing Rails applications against multiple versions of Rails. 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: * easily test plugins/extensions using a require from your test_helper.rb and a require in your RakeFile * rake tasks to test against a specified version of Rails, the latest version, or all versions * tentative support for testing plain Rails apps against multiple versions of Rails * Uses rubygems for version management of Rails #### TODOs: * improve docs on how to override what files are required by multi_rails * maybe add ability to load plain Rails versions -- ie checked out copies not in RubyGems #### NOTES: * (__For Rails apps only__) multi_rails will rename your vendor/rails directory to vendor/rails.off if it finds one within your rails app. We have to do this to make Rails fall back to RubyGems rails. Multi_rails will rename back to the correct vendor/rails when done testing, so it will not interrupt your app in normal use. * (__For Rails apps only__) multi_rails needs to add a line to top of your environment.rb to hook into -- see the instructions below for more details"
16
16
  autorequire:
17
17
  default_executable:
18
18
  bindir: bin
@@ -30,12 +30,15 @@ post_install_message:
30
30
  authors:
31
31
  - Relevance
32
32
  files:
33
+ - .autotest
33
34
  - History.txt
34
35
  - MIT-LICENSE
35
36
  - Manifest.txt
36
37
  - README.txt
37
38
  - Rakefile
39
+ - autotest.rb
38
40
  - bin/multi_rails_runner.rb
41
+ - credits.txt
39
42
  - install.rb
40
43
  - lib/multi_rails.rb
41
44
  - lib/multi_rails/config.rb
@@ -46,6 +49,7 @@ files:
46
49
  - lib/multi_rails_init.rb
47
50
  - tasks/load_multi_rails_rake_tasks.rb
48
51
  - tasks/multi_rails.rake
52
+ - test/autotest/railsplugin.rb
49
53
  - test/config_test.rb
50
54
  - test/core_extensions_test.rb
51
55
  - test/install_test.rb
@@ -67,6 +71,7 @@ extra_rdoc_files:
67
71
  - History.txt
68
72
  - Manifest.txt
69
73
  - README.txt
74
+ - credits.txt
70
75
  executables:
71
76
  - multi_rails_runner.rb
72
77
  extensions: []