Permalink
Browse files

testing

  • Loading branch information...
1 parent 3b0e461 commit a0c30a81ad3a78c0cc5388e99d8153075c25629c @fguillen fguillen committed Oct 19, 2010
View
@@ -1,10 +1,14 @@
Manifest
README.rdoc
Rakefile
-lib/simplecov-csv.rb
+lib/simplecov-rcov.rb
test/fixtures/app/controllers/sample_controller.rb
test/fixtures/app/models/user.rb
-test/fixtures/results.csv
+test/fixtures/file_tr.html
+test/fixtures/index_created.html
+test/fixtures/index_rcov.html
test/fixtures/sample.rb
+test/fixtures/totals_tr.html
test/helper.rb
-test/simplecov-csv_test.rb
+test/simplecov-rcov_test.rb
+views/index.erb.html
View
@@ -17,7 +17,7 @@ The target of this formatter is to cheat on Hudson so I can use the {Ruby metric
== TODO
-The actual version generates only one simple index.html file.
+The actual version generates only one simple */rcov/index.html* file.
== Credits
View
@@ -2,9 +2,9 @@ require 'rubygems'
require 'rake'
require 'echoe'
-Echoe.new('simplecov-csv', '0.1.3') do |p|
- p.description = "CSV formatter for SimpleCov"
- p.url = "http://github.com/fguillen/simplecov-csv"
+Echoe.new('simplecov-rcov', '0.1.0') do |p|
+ p.description = "Rcov style formatter for SimpleCov"
+ p.url = "http://github.com/fguillen/simplecov-rcov"
p.author = "Fernando Guillen http://fernandoguillen.info"
p.email = "fguillen.mail@gmail.com"
p.ignore_pattern = ["tmp/*", "script/*"]
View
@@ -4,8 +4,9 @@ class SimpleCov::Formatter::RcovFormatter
def format( result )
@files = result.files
- @covered_percent = result.covered_percent
- @total_lines = result.files.map(&:covered_percent).inject(:+) / files.count.to_f
+ @total_lines = result.files.map { |e| e.lines.count }.inject(:+)
+ @total_lines_code = result.files.map { |e| e.covered_lines.count + e.missed_lines.count }.inject(:+)
+ @total_coverage = result.covered_percent
template = ERB.new( File.read( "#{File.dirname(__FILE__)}/../views/index.erb.html" ) )
rcov_result = template.result( binding )
@@ -16,14 +17,14 @@ def format( result )
file_result.write rcov_result
end
- puts "Coverage report generated for #{result.command_name} to #{SimpleCov::Formatter::RcovFormatter.path_result}"
+ puts "Coverage report Rcov style generated for #{result.command_name} to #{SimpleCov::Formatter::RcovFormatter.path_result}"
return rcov_result
end
private
def self.path_result
- File.join( SimpleCov.coverage_path, SimpleCov::Formatter::CSVFormatter::PATH_RESULT )
+ File.join( SimpleCov.coverage_path, SimpleCov::Formatter::RcovFormatter::PATH_RESULT )
end
end
@@ -0,0 +1,6 @@
+fixtures/app/controllers/sample_controller.rb</td>
+ <td class='right_align'><tt>10</tt></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class="left_align"><tt class=''>60.00%</tt></td>
+ <td class="left_align"><tt class=''>60.00%</tt></td>
+ </tr>
@@ -21,32 +21,32 @@
<tfoot>
<tr>
<td class="left_align">TOTAL</td>
- <td class='right_align'><tt>1019</tt></td>
- <td class='right_align'><tt>757</tt></td>
- <td class="left_align"><tt class=''>89.21%</tt></td>
- <td class="left_align"><tt class='coverage_total'>86.13%</tt></td>
+ <td class='right_align'><tt>30</tt></td>
+ <td class='right_align'><tt>15</tt></td>
+ <td class="left_align"><tt class=''>80.00%</tt></td>
+ <td class="left_align"><tt class='coverage_total'>80.00%</tt></td>
</tr>
</tfoot>
<tbody>
<tr class="all_files all_coverage 70 80 90 100 app controllers even">
- <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/controllers/sample_controller.rb</td>
+ <td class="left_align">./fixtures/app/controllers/sample_controller.rb</td>
<td class='right_align'><tt>10</tt></td>
<td class='right_align'><tt>5</tt></td>
<td class="left_align"><tt class=''>60.00%</tt></td>
<td class="left_align"><tt class=''>60.00%</tt></td>
</tr>
<tr class="all_files all_coverage 70 80 90 100 app controllers even">
- <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/models/user.rb</td>
+ <td class="left_align">./fixtures/app/models/user.rb</td>
<td class='right_align'><tt>10</tt></td>
<td class='right_align'><tt>5</tt></td>
<td class="left_align"><tt class=''>80.00%</tt></td>
<td class="left_align"><tt class=''>80.00%</tt></td>
</tr>
<tr class="all_files all_coverage 70 80 90 100 app controllers even">
- <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/sample.rb</td>
+ <td class="left_align">./fixtures/sample.rb</td>
<td class='right_align'><tt>10</tt></td>
<td class='right_align'><tt>5</tt></td>
<td class="left_align"><tt class=''>100.00%</tt></td>
File renamed without changes.
@@ -1,4 +0,0 @@
-File,% covered,Lines,Relevant Lines,Lines covered,Lines missed
-"./fixtures/app/controllers/sample_controller.rb",60,10,5,3,2
-"./fixtures/app/models/user.rb",80,10,5,4,1
-"./fixtures/sample.rb",100,10,5,5,0
@@ -0,0 +1,7 @@
+ <tr>
+ <td class="left_align">TOTAL</td>
+ <td class='right_align'><tt>30</tt></td>
+ <td class='right_align'><tt>15</tt></td>
+ <td class="left_align"><tt class=''>80.00%</tt></td>
+ <td class="left_align"><tt class='coverage_total'>80.00%</tt></td>
+ </tr>
@@ -1,61 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
- <head>
- <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
- <title>SimpleCov - RCov style</title>
- </head>
- <body>
- <h1>SimpleCov - RCov style</h1>
-
- <div class="report_table_wrapper">
- <table class='report' id='report_table'>
- <thead>
- <tr>
- <th class="left_align">Name</th>
- <th class="right_align">Total Lines</th>
- <th class="right_align">Lines of Code</th>
- <th class="left_align">Total Coverage</th>
- <th class="left_align">Code Coverage</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <td class="left_align">TOTAL</td>
- <td class='right_align'><tt>1019</tt></td>
- <td class='right_align'><tt>757</tt></td>
- <td class="left_align"><tt class=''>89.21%</tt></td>
- <td class="left_align"><tt class='coverage_total'>86.13%</tt></td>
- </tr>
- </tfoot>
- <tbody>
-
- <tr class="all_files all_coverage 70 80 90 100 app controllers even">
- <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/controllers/sample_controller.rb</td>
- <td class='right_align'><tt>10</tt></td>
- <td class='right_align'><tt>5</tt></td>
- <td class="left_align"><tt class=''>60.00%</tt></td>
- <td class="left_align"><tt class=''>60.00%</tt></td>
- </tr>
-
- <tr class="all_files all_coverage 70 80 90 100 app controllers even">
- <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/models/user.rb</td>
- <td class='right_align'><tt>10</tt></td>
- <td class='right_align'><tt>5</tt></td>
- <td class="left_align"><tt class=''>80.00%</tt></td>
- <td class="left_align"><tt class=''>80.00%</tt></td>
- </tr>
-
- <tr class="all_files all_coverage 70 80 90 100 app controllers even">
- <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/sample.rb</td>
- <td class='right_align'><tt>10</tt></td>
- <td class='right_align'><tt>5</tt></td>
- <td class="left_align"><tt class=''>100.00%</tt></td>
- <td class="left_align"><tt class=''>100.00%</tt></td>
- </tr>
-
- </tbody>
- </table>
- </div>
-
- </body>
-</html>
@@ -2,8 +2,7 @@
class SimplecovRcovFormatterTest < Test::Unit::TestCase
def test_format
- SimpleCov.stubs( :coverage_path ).returns( "/tmp" )
- SimpleCov::Formatter::RcovFormatter.stubs( :path_result ).returns( 'rcov/coverage_test_index.html' )
+ SimpleCov::Formatter::RcovFormatter.stubs( :path_result ).returns( '/tmp/rcov/coverage_test_index.html' )
if File.exists?( SimpleCov::Formatter::RcovFormatter.path_result )
File.delete( SimpleCov::Formatter::RcovFormatter.path_result )
end
@@ -15,15 +14,10 @@ def test_format
}
@result = SimpleCov::Result.new( @original_result )
- puts "XXX: @result: #{@result}"
rcov_result = SimpleCov::Formatter::RcovFormatter.new().format( @result )
- # File.open( "#{File.dirname(__FILE__)}/fixtures/index_1.html", 'w' ) { |f| f.write rcov_result }
-
- # File.readlines( source_fixture( 'results.csv' ) ).each do |line|
- # assert_match( line.gsub( /^"\./, '' ), csv_result )
- # end
-
+ assert_match( File.read( "#{File.dirname(__FILE__)}/fixtures/totals_tr.html"), rcov_result )
+ assert_match( File.read( "#{File.dirname(__FILE__)}/fixtures/file_tr.html"), rcov_result )
assert( File.exists?( SimpleCov::Formatter::RcovFormatter.path_result ) )
end
View
@@ -21,16 +21,16 @@
<tfoot>
<tr>
<td class="left_align">TOTAL</td>
- <td class='right_align'><tt>1019</tt></td>
- <td class='right_align'><tt>757</tt></td>
- <td class="left_align"><tt class=''>89.21%</tt></td>
- <td class="left_align"><tt class='coverage_total'>86.13%</tt></td>
+ <td class='right_align'><tt><%= @total_lines %></tt></td>
+ <td class='right_align'><tt><%= @total_lines_code %></tt></td>
+ <td class="left_align"><tt class=''><%= '%.2f' % @total_coverage %>%</tt></td>
+ <td class="left_align"><tt class='coverage_total'><%= '%.2f' % @total_coverage %>%</tt></td>
</tr>
</tfoot>
<tbody>
<% @files.each do |file| %>
- <tr class="all_files all_coverage 70 80 90 100 app controllers even">
- <td class="left_align"><a href="app-controllers-application_controller_rb.html"><%= file.filename.gsub(SimpleCov.root, '.') %></td>
+ <tr class="all_files">
+ <td class="left_align"><%= file.filename.gsub(SimpleCov.root, '.') %></td>
<td class='right_align'><tt><%= file.lines.count %></tt></td>
<td class='right_align'><tt><%= file.covered_lines.count + file.missed_lines.count %></tt></td>
<td class="left_align"><tt class=''><%= '%.2f' % file.covered_percent %>%</tt></td>

0 comments on commit a0c30a8

Please sign in to comment.