Skip to content

Commit

Permalink
Progress hacking Rake test runners to work with zeus. Getting close
Browse files Browse the repository at this point in the history
  • Loading branch information
burke committed Sep 16, 2012
1 parent 512ca4a commit 0249b34
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rubygem/lib/zeus/m.rb
Expand Up @@ -149,10 +149,10 @@ def add_file(arg)
if Dir.exist?(file)
files = Dir.glob("#{file}/**/*test*.rb")
@files.concat(files)
elsif File.exist?(file)
@files << file
else
abort "Couldn't find test file '#{file}'!"
files = Dir.glob(file)
files == [] and abort "Couldn't find test file '#{file}'!"
@files.concat(files)
end
end

Expand Down
41 changes: 41 additions & 0 deletions rubygem/lib/zeus/rails.rb
Expand Up @@ -22,7 +22,48 @@ def after_fork
reconnect_redis
end

def _monkeypatch_rake
require 'rake/testtask'
Rake::TestTask.class_eval {

# Create the tasks defined by this task lib.
def define
desc "Run tests" + (@name==:test ? "" : " for #{@name}")
task @name do
Rake::FileUtilsExt.verbose(@verbose) do
# ruby "#{ruby_opts_string} #{run_code} #{file_list_string} #{option_list}"
prev = ENV['RAILS_ENV']
ENV['RAILS_ENV'] = nil
sh "zeus test #{file_list_string}"
ENV['RAILS_ENV'] = prev
end
end
self
end

alias_method :_original_define, :define

def self.inherited(klass)
return unless klass.name == "TestTaskWithoutDescription"
klass.class_eval {
def self.method_added(sym)
class_eval do
if !@rails_hack_reversed
@rails_hack_reversed = true
alias_method :define, :_original_define
def desc(*)
end
end
end
end
}
end
}
end

def boot
_monkeypatch_rake

require BOOT_PATH
# config/application.rb normally requires 'rails/all'.
# Some 'alternative' ORMs such as Mongoid give instructions to switch this require
Expand Down

0 comments on commit 0249b34

Please sign in to comment.