Permalink
Browse files

Ticket 2297 - rake stats clearly labels functional and unit tests

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2373 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent fcd0133 commit ec019d7bc17e7bcf99545fa7698b3bcb419d2632 @jeremy jeremy committed Sep 27, 2005
Showing with 14 additions and 11 deletions.
  1. +6 −3 railties/lib/code_statistics.rb
  2. +8 −8 railties/lib/tasks/statistics.rake
@@ -1,4 +1,7 @@
class CodeStatistics
+
+ TEST_TYPES = ['Unit tests', 'Functional tests']
+
def initialize(*pairs)
@pairs = pairs
@statistics = calculate_statistics
@@ -55,13 +58,13 @@ def calculate_total
def calculate_code
code_loc = 0
- @statistics.each { |k, v| code_loc += v['codelines'] unless ['Units', 'Functionals'].include? k }
+ @statistics.each { |k, v| code_loc += v['codelines'] unless TEST_TYPES.include? k }
code_loc
end
def calculate_tests
test_loc = 0
- @statistics.each { |k, v| test_loc += v['codelines'] if ['Units', 'Functionals'].include? k }
+ @statistics.each { |k, v| test_loc += v['codelines'] if TEST_TYPES.include? k }
test_loc
end
@@ -79,7 +82,7 @@ def print_line(name, statistics)
m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0
loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0
- start = if ['Units', 'Functionals'].include? name
+ start = if TEST_TYPES.include? name
"| #{name.ljust(18)} "
else
"| #{name.ljust(20)} "
@@ -1,12 +1,12 @@
STATS_DIRECTORIES = [
- %w(Helpers app/helpers),
- %w(Controllers app/controllers),
- %w(APIs app/apis),
- %w(Components components),
- %w(Functionals test/functional),
- %w(Models app/models),
- %w(Units test/unit),
- %w(Libraries lib/)
+ %w(Helpers app/helpers),
+ %w(Controllers app/controllers),
+ %w(APIs app/apis),
+ %w(Components components),
+ %w(Functional\ tests test/functional),
+ %w(Models app/models),
+ %w(Unit\ tests test/unit),
+ %w(Libraries lib/)
].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
desc "Report code statistics (KLOCs, etc) from the application"

0 comments on commit ec019d7

Please sign in to comment.