Skip to content

Instantly share code, notes, and snippets.

@Stray
Created March 19, 2010 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Stray/337532 to your computer and use it in GitHub Desktop.
Save Stray/337532 to your computer and use it in GitHub Desktop.
# rake file sugar for project sprouts
# to specify a package to be tested: rake testpackage['packagename']
# you can also use a package name that recurs as a filter: rake testpackage['api']
# if you like, you can be more specific: rake testpackage['somepackage.model']
# to restore all tests: rake testall
# note: these tasks edit the AllTests.as file.
desc 'Prepare the AllTests class to test a specific package'
task :testpackage, :packageName do |t, args|
tempFile = File.new("test/temp.as", "w");
allTestsFile = File.open("test/AllTests.as", "r");
allTestsFile.each do |line|
line = line.gsub('//','')
if(line.include?('addTest'))
if !(line.include?(args.packageName))
line = '//' + line
end
end
tempFile.write(line)
end
tempFile.close
allTestsFile.close
File.delete("test/AllTests.as")
File.rename("test/temp.as", "test/AllTests.as")
Rake::Task[ "test" ].invoke
end
desc 'Set all tests active in the AllTests.as package'
task :testall do
tempFile = File.new("test/temp.as", "w");
allTestsFile = File.open("test/AllTests.as", "r");
allTestsFile.each do |line|
line = line.gsub('//','')
tempFile.write(line)
end
tempFile.close
allTestsFile.close
File.delete("test/AllTests.as")
File.rename("test/temp.as", "test/AllTests.as")
Rake::Task[ "test" ].invoke
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment