Skip to content

Instantly share code, notes, and snippets.

@mikz
Created November 15, 2012 16:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikz/4079488 to your computer and use it in GitHub Desktop.
Save mikz/4079488 to your computer and use it in GitHub Desktop.
Tiny script to run ruby files or run all files in directory (usefull for tests)
alias rt="ruby -Itest -I. -e \"alias rt="ruby -Itest -I. -e \"require'pathname';P=Pathname;ARGV.map{|a|p=P.new(a);next unless p.exist?;p.directory?? P.glob(p.join('**/*.rb')):p}.flatten.compact.uniq.each{|p|require p.expand_path}\""\""
rt test/unit/cms/ # runs all tests in that folder
rt test/unit/contract_test.rb test/unit/user_test.rb # runs both files
rt test/unit/contract/*_user* # runs all tests matching the glob
#!/usr/bin/env ruby -Itest -I.
require'pathname';P=Pathname;ARGV.map{|a|p=P.new(a);next unless p.exist?;p.directory?? P.glob(p.join('**/*.rb')):p}.flatten.compact.uniq.each{|p|require p.expand_path}
#!/usr/bin/env ruby -Itest -I.
require 'pathname'
paths = ARGV.map do |arg|
path = Pathname.new(arg)
next unless arg.exist?
if path.directory?
Pathname.glob path.join('**/*.rb')
else
path
end
end
paths.flatten.compact.uniq.each { |path| require path.expand_path }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment