Permalink
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (59 sloc) 1.9 KB
path = File.expand_path(File.dirname(__FILE__))
modules = []
files = ARGV
files = nil if files.length == 0
if ENV['COMPONENT']
modules = ENV['COMPONENT'].split(",")
elsif ENV['NO_COMPONENTS']
modules = []
else
Dir.glob("#{path}/vendor/modules/[a-z0-9_]*") do |file|
if file =~ /\/([a-z_0-9-]+)\/{0,1}$/
modules << $1
end
end
end
Autotest.add_hook :initialize do |at|
%w{.hg .git tmtags Rakefile Capfile README spec/spec.opts spec/rcov.opts}.each {|exception|at.add_exception(exception)}
if ENV['COMPONENT'] || files
at.clear_mappings()
end
at.add_exception("public/")
at.remove_exception("log/") # f-ing blog
at.add_exception("log/*.log")
at.add_exception("log.log")
at.add_exception("*.log")
at.add_exception("*.pid")
at.add_exception("backup/")
at.add_exception('log/test.log')
if files
files.each do |file|
at.add_mapping %r%^#{file}$% do |filename,matches|
if file =~ /^(lib|app)\/(.*)\.rb$/
partfile = $2
if $1 == 'lib'
partfile = "lib/" + partfile
end
at.files_matching( %r%^spec/#{partfile}_spec.rb$% )
end
end
end
else
modules.each do |mod|
%w(controllers models views lib).each do |type|
at.add_mapping %r%^vendor/modules/#{mod}/app/#{type}/(.*)\.rb$% do |filename,matches|
at.files_matching(/^vendor\/modules\/#{mod}\/spec\/#{type}\/#{matches[1]}_spec.rb$/)
end
at.add_mapping %r%^vendor/modules/#{mod}/spec/#{type}/(.*)_spec\.rb$% do |filename,matches|
at.files_matching(/^vendor\/modules\/#{mod}\/spec\/#{type}\/#{matches[1]}_spec.rb$/)
end
end
end
end
end
#Autotest.add_hook :initialize do |at|
# at.add_mapping(%r%^acts_as_currency/lib/.*\.rb$%) {
# at.files_matching %r%^spec/models/product_spec\.rb$% +
# at.files_matching %r%^plugins/acts_as_currency/spec/.*_spec\.rb$%
# }
#end