Created
July 8, 2009 19:32
-
-
Save ryanbriones/143118 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/ruby | |
| # run coverage on a single file in rails project | |
| require 'fileutils' | |
| RCOV_OPTS = File.read(File.join(Dir.pwd, 'spec/rcov.opts')).split(/\r?\n/) | |
| FILES_TO_RCOV = ARGV | |
| SPECS_TO_RCOV = FILES_TO_RCOV.collect do |file| | |
| spec = "spec/#{file.sub(/^app\//, '').sub(/\.rb$/, '_spec.rb')}" | |
| unless File.exists?(File.join(Dir.pwd, spec)) | |
| STDERR.puts "Missing spec: #{File.join(Dir.pwd, spec)}" | |
| next | |
| end | |
| spec | |
| end.compact | |
| FileUtils.rm_r(File.join(Dir.pwd, 'coverage')) if File.exists?(File.join(Dir.pwd, 'coverage')) | |
| puts("ruby -S rcov #{RCOV_OPTS.join(' ')} --exclude 'app/*,db/*,lib/*,spec/*,config/*,vendor/*,script/*' -i '#{FILES_TO_RCOV.join(',')}' #{`which spec`.chomp} -- #{SPECS_TO_RCOV.join(' ')}") | |
| system("rcov #{RCOV_OPTS.join(' ')} --exclude 'app/*,db/*,lib/*,spec/*,config/*,vendor/*,script/*' -i '#{FILES_TO_RCOV.join(',')}' `which spec` -- #{SPECS_TO_RCOV.join(' ')}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment