Yesterday, David released RSpec 1.2.7, which includes a patch I provided to allow the specification of where to find the 'ruby' program when creating a SpecTask, rather than relying Rakes RUBY variable.
Why did I submit this patch you ask, assuming you didn't read the title of this post?
So you can do this in a Rakefile :
multiruby_path = `which multiruby`.chomp
if multiruby_path.length > 0 && Spec::Rake::SpecTask.instance_methods.include?("ruby_cmd")
namespace :spec do
desc "Run all specs with multiruby and ActiveSupport"
Spec::Rake::SpecTask.new(:multi) do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/**/*_spec.rb']
t.ruby_cmd = multiruby_path
end
end
end
This is derived from something I just added to RiCal but haven't yet released.
What it does is check that you have multiruby, which is part of the zentest gem, installed, and that your version of RSpec supports the new ruby_cmd option. If both conditions are met it makes a spec task which runs the specs using multiruby instead of ruby.
Now it's easy to run specs with the various ruby versions you want to support.