Created
November 4, 2009 18:49
-
-
Save mattscilipoti/226284 to your computer and use it in GitHub Desktop.
rake -g spec:recent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#save to ~/.rake/rspec_recent.rake | |
@usage: `rake -g spec:recent` | |
# Grab recently touched specs | |
#from: http://nullcreations.net/entries/general/rspec-on-rails-rake-task-for-recent-specs | |
#TODO: should this grab list from svn? affter we remove externals? | |
def recent_specs(touched_since) | |
recent_specs = FileList['app/**/*'].map do |path| | |
if File.mtime(path) > touched_since | |
spec = File.join('spec', File.dirname(path).split("/")[1..-1].join('/'), | |
"#{File.basename(path, ".*")}_spec.rb") | |
spec if File.exists?(spec) | |
end | |
end.compact | |
recent_specs += FileList['spec/**/*_spec.rb'].select do |path| | |
File.mtime(path) > touched_since | |
end | |
recent_specs.uniq | |
end | |
#TODO: Add ability to pass in touched_since from command line | |
desc 'Run specs for files which have changed in the last 60 min.' | |
Spec::Rake::SpecTask.new("spec:recent") do |t| | |
t.spec_opts = ["--format","specdoc","--color"] | |
t.spec_files = recent_specs(Time.now - 360) # 60 min. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment