simplecov 0.3.7 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,2 @@
1
1
  source "http://rubygems.org"
2
-
3
- gem "simplecov-html", ">= 0.3.7"
4
- group :development do
5
- gem "shoulda", "= 2.10.3"
6
- gem "rspec", "~> 2.0.0"
7
- gem "jeweler", "= 1.4.0"
8
- end
2
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,14 +1,13 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simplecov (0.3.9)
5
+ simplecov-html (>= 0.3.7)
6
+
1
7
  GEM
2
8
  remote: http://rubygems.org/
3
9
  specs:
4
10
  diff-lcs (1.1.2)
5
- gemcutter (0.6.1)
6
- git (1.2.5)
7
- jeweler (1.4.0)
8
- gemcutter (>= 0.1.0)
9
- git (>= 1.2.5)
10
- rubyforge (>= 2.0.0)
11
- json_pure (1.4.6)
12
11
  rspec (2.0.1)
13
12
  rspec-core (~> 2.0.1)
14
13
  rspec-expectations (~> 2.0.1)
@@ -19,8 +18,6 @@ GEM
19
18
  rspec-mocks (2.0.1)
20
19
  rspec-core (~> 2.0.1)
21
20
  rspec-expectations (~> 2.0.1)
22
- rubyforge (2.0.4)
23
- json_pure (>= 1.1.7)
24
21
  shoulda (2.10.3)
25
22
  simplecov-html (0.3.8)
26
23
 
@@ -28,7 +25,7 @@ PLATFORMS
28
25
  ruby
29
26
 
30
27
  DEPENDENCIES
31
- jeweler (= 1.4.0)
32
28
  rspec (~> 2.0.0)
33
29
  shoulda (= 2.10.3)
30
+ simplecov!
34
31
  simplecov-html (>= 0.3.7)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Christoph Olszowka
1
+ Copyright (c) 2010-2011 Christoph Olszowka
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,21 +1,22 @@
1
- = simplecov
1
+ = SimpleCov
2
2
 
3
3
  SimpleCov is a code coverage analysis tool for Ruby 1.9. It uses 1.9's built-in Coverage library to gather code
4
4
  coverage data, but makes processing it's results much easier by providing a clean API to filter, group, merge, format
5
- and display those results, thus giving you a complete code coverage suite with just a couple lines of code.
5
+ and display those results, thus giving you a complete code coverage suite that can be set up with just a couple lines of
6
+ code.
6
7
 
7
8
  In most cases, you'll want overall coverage results for your projects, including all types of tests, cucumber features
8
9
  etc. Simplecov automatically takes care of this by caching and then merging results when generating reports, so your
9
- coverage report gives you a more accurate report on the blank spots in your test coverage.
10
+ report actually covers coverage across your test suites and thereby gives you a better picture of blank spots.
10
11
 
11
- The official formatter of SimpleCov is packaged as a separate gem called simplecov-html and will be installed automatically
12
- when you do gem install simplecov. You can find it at http://github.com/colszowka/simplecov-html
12
+ The official formatter of SimpleCov is packaged as a separate gem called simplecov-html but will be installed and configured
13
+ automatically when you launch SimpleCov. If you're curious, you can find it at http://github.com/colszowka/simplecov-html
13
14
 
14
15
  == Basic usage
15
16
 
16
17
  Update your Gemfile with this and do a bundle install:
17
18
  group :test do
18
- gem 'simplecov', '>= 0.3.5', :require => false # Will install simplecov-html as a dependency
19
+ gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
19
20
  end
20
21
 
21
22
  Then, add the following to your Rails test/test_helper.rb (right at the top, line 00):
@@ -250,6 +251,40 @@ You can use your own formatter with:
250
251
  When calling SimpleCov.result.format!, it will be invoked with SimpleCov::Formatter::YourFormatter.new.format(result), "result"
251
252
  being an instance of SimpleCov::Result. Do whatever your wish with that!
252
253
 
254
+ == Using multiple formatters
255
+
256
+ There is currently no built-in support for this, but you could help yourself with a wrapper class:
257
+
258
+ class SimpleCov::Formatter::MergedFormatter
259
+ def format(result)
260
+ SimpleCov::Formatter::HTMLFormatter.new.format(result)
261
+ SimpleCov::Formatter::CSVFormatter.new.format(result)
262
+ end
263
+ end
264
+
265
+ Then configure the formatter to use the new merger:
266
+
267
+ SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
268
+
269
+ == Available formatters
270
+
271
+ Apart from the direct companion simplecov-html (https://github.com/colszowka/simplecov-html), there are other formatters
272
+ available:
273
+
274
+ ==== simplecov_rcov
275
+ by Fernando Guillen
276
+
277
+ https://github.com/fguillen/simplecov-rcov
278
+
279
+ "The target of this formatter is to cheat on Hudson so I can use the Ruby metrics plugin with SimpleCov."
280
+
281
+ ==== simplecov_csv
282
+ by Fernando Guillen
283
+
284
+ https://github.com/fguillen/simplecov-csv
285
+
286
+ CSV formatter for SimpleCov code coverage tool for ruby 1.9+
287
+
253
288
  == Configuration options
254
289
 
255
290
  === SimpleCov.root '/some/path/to/coverage'
@@ -270,8 +305,25 @@ Thanks to Aaron Patterson (http://engineering.attinteractive.com/2010/08/code-co
270
305
  for this!
271
306
 
272
307
  == TODO
308
+
273
309
  * Improve on tests (integration tests)
274
310
 
311
+ == Developer notes
312
+
313
+ The test suite is built for execution on multiple versions of Ruby to ensure that SimpleCov keeps quiet on Ruby 1.8.
314
+
315
+ RVM is used for that, and let me tell you that you probably want to install it if you haven't yet.
316
+
317
+ To invoke the test suite on multiple rubies, install the dev bundle using
318
+
319
+ rake multitest:bundle
320
+
321
+ and then you should be ready to launch the tests:
322
+
323
+ rake multitest
324
+
325
+ The ruby versions used for testing can be found in the Rakefile.
326
+
275
327
  == Note on Patches/Pull Requests
276
328
 
277
329
  * Fork the project.
@@ -284,4 +336,4 @@ for this!
284
336
 
285
337
  == Copyright
286
338
 
287
- Copyright (c) 2010 Christoph Olszowka. See LICENSE for details.
339
+ Copyright (c) 2010-2011 Christoph Olszowka. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,25 +1,5 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "simplecov"
8
- gem.summary = %Q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
9
- gem.description = %Q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
10
- gem.email = "christoph at olszowka de"
11
- gem.homepage = "http://github.com/colszowka/simplecov"
12
- gem.authors = ["Christoph Olszowka"]
13
- gem.add_dependency 'simplecov-html', ">= 0.3.7"
14
- gem.add_development_dependency "shoulda", "2.10.3"
15
- gem.add_development_dependency "rspec", "~> 2.0.0"
16
- gem.add_development_dependency "jeweler", "1.4.0"
17
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
23
3
 
24
4
  require 'rake/testtask'
25
5
  Rake::TestTask.new(:test) do |test|
@@ -28,16 +8,24 @@ Rake::TestTask.new(:test) do |test|
28
8
  test.verbose = true
29
9
  end
30
10
 
31
- task :test => :check_dependencies
32
-
33
11
  task :default => :test
34
12
 
35
13
  require 'rake/rdoctask'
36
14
  Rake::RDocTask.new do |rdoc|
37
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
38
-
39
15
  rdoc.rdoc_dir = 'rdoc'
40
- rdoc.title = "simplecov #{version}"
41
16
  rdoc.rdoc_files.include('README*')
42
17
  rdoc.rdoc_files.include('lib/**/*.rb')
43
18
  end
19
+
20
+ TestedRubyVersions = %w(1.9.2 1.8.7 1.8.6)
21
+
22
+ desc "Perorms bundle install on all rvm-tested ruby versions (#{TestedRubyVersions.join(', ')})"
23
+ task :"multitest:bundle" do
24
+ system "rvm #{TestedRubyVersions.join(',')} exec bundle install"
25
+ end
26
+
27
+ desc "Runs tests using rvm for: #{TestedRubyVersions.join(', ')}"
28
+ task :multitest do
29
+ system "rvm #{TestedRubyVersions.join(',')} rake test"
30
+ end
31
+
data/lib/simplecov.rb CHANGED
@@ -5,9 +5,6 @@ module SimpleCov
5
5
  # Indicates invalid coverage data
6
6
  class CoverageDataError < StandardError; end;
7
7
 
8
- # The version of the simplecov gem
9
- VERSION = File.read(File.join(File.dirname(__FILE__), '../VERSION'))
10
-
11
8
  class << self
12
9
  attr_accessor :running#, :result # TODO: Remove result?
13
10
 
@@ -29,10 +26,8 @@ module SimpleCov
29
26
  # Please check out the RDoc for SimpleCov::Configuration to find about available config options
30
27
  #
31
28
  def start(adapter=nil, &block)
32
- unless "1.9".respond_to?(:encoding)
33
- warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9 - no coverage analysis will happen"
34
- return false
35
- end
29
+ return false unless SimpleCov.usable?
30
+
36
31
  require 'coverage'
37
32
  load_adapter(adapter) unless adapter.nil?
38
33
  Coverage.start
@@ -93,6 +88,17 @@ module SimpleCov
93
88
  adapters.load(name)
94
89
  end
95
90
 
91
+ #
92
+ # Checks whether we're on a proper version of ruby (1.9+) and returns false if this is not the case,
93
+ # also printing an appropriate warning
94
+ #
95
+ def usable?
96
+ unless "1.9".respond_to?(:encoding)
97
+ warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
98
+ return false
99
+ end
100
+ true
101
+ end
96
102
  end
97
103
  end
98
104
 
@@ -107,6 +113,9 @@ require 'simplecov/formatter'
107
113
  require 'simplecov/merge_helpers'
108
114
  require 'simplecov/result_merger'
109
115
  require 'simplecov/command_guesser'
116
+ require 'simplecov/version'
117
+
118
+ # Load formatter gem
110
119
  require 'simplecov-html'
111
120
 
112
121
  # Default configuration
@@ -99,6 +99,7 @@ module SimpleCov::Configuration
99
99
  # options at once.
100
100
  #
101
101
  def configure(&block)
102
+ return false unless SimpleCov.usable?
102
103
  instance_exec(&block)
103
104
  end
104
105
 
@@ -6,7 +6,7 @@ module SimpleCov
6
6
  # A simplecov code coverage result, initialized from the Hash Ruby 1.9's built-in coverage
7
7
  # library generates (Coverage.result).
8
8
  #
9
- class Result
9
+ class Result
10
10
  # Returns the original Coverage.result used for this instance of SimpleCov::Result
11
11
  attr_reader :original_result
12
12
  # Returns all files that are applicable to this result (sans filters!) as instances of SimpleCov::SourceFile. Aliased as :source_files
@@ -0,0 +1,3 @@
1
+ module SimpleCov
2
+ VERSION = "0.3.9"
3
+ end
data/simplecov.gemspec CHANGED
@@ -1,106 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "simplecov/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{simplecov}
8
- s.version = "0.3.7"
6
+ s.name = "simplecov"
7
+ s.version = SimpleCov::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Christoph Olszowka"]
10
+ s.email = ["christoph at olszowka de"]
11
+ s.homepage = "http://github.com/colszowka/simplecov"
12
+ s.summary = %Q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
13
+ s.description = %Q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Christoph Olszowka"]
12
- s.date = %q{2010-11-06}
13
- s.description = %q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
14
- s.email = %q{christoph at olszowka de}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- ".rvmrc",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE",
26
- "README.rdoc",
27
- "Rakefile",
28
- "VERSION",
29
- "lib/simplecov.rb",
30
- "lib/simplecov/adapters.rb",
31
- "lib/simplecov/command_guesser.rb",
32
- "lib/simplecov/configuration.rb",
33
- "lib/simplecov/filter.rb",
34
- "lib/simplecov/formatter.rb",
35
- "lib/simplecov/formatter/simple_formatter.rb",
36
- "lib/simplecov/merge_helpers.rb",
37
- "lib/simplecov/result.rb",
38
- "lib/simplecov/result_merger.rb",
39
- "lib/simplecov/source_file.rb",
40
- "simplecov.gemspec",
41
- "test/fixtures/app/controllers/sample_controller.rb",
42
- "test/fixtures/app/models/user.rb",
43
- "test/fixtures/frameworks/rspec_bad.rb",
44
- "test/fixtures/frameworks/rspec_good.rb",
45
- "test/fixtures/frameworks/testunit_bad.rb",
46
- "test/fixtures/frameworks/testunit_good.rb",
47
- "test/fixtures/resultset1.rb",
48
- "test/fixtures/resultset2.rb",
49
- "test/fixtures/sample.rb",
50
- "test/helper.rb",
51
- "test/test_command_guesser.rb",
52
- "test/test_filters.rb",
53
- "test/test_merge_helpers.rb",
54
- "test/test_result.rb",
55
- "test/test_return_codes.rb",
56
- "test/test_source_file.rb",
57
- "test/test_source_file_line.rb"
58
- ]
59
- s.homepage = %q{http://github.com/colszowka/simplecov}
60
- s.rdoc_options = ["--charset=UTF-8"]
61
- s.require_paths = ["lib"]
62
- s.rubygems_version = %q{1.3.7}
63
- s.summary = %q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
64
- s.test_files = [
65
- "test/fixtures/app/controllers/sample_controller.rb",
66
- "test/fixtures/app/models/user.rb",
67
- "test/fixtures/frameworks/rspec_bad.rb",
68
- "test/fixtures/frameworks/rspec_good.rb",
69
- "test/fixtures/frameworks/testunit_bad.rb",
70
- "test/fixtures/frameworks/testunit_good.rb",
71
- "test/fixtures/resultset1.rb",
72
- "test/fixtures/resultset2.rb",
73
- "test/fixtures/sample.rb",
74
- "test/helper.rb",
75
- "test/test_command_guesser.rb",
76
- "test/test_filters.rb",
77
- "test/test_merge_helpers.rb",
78
- "test/test_result.rb",
79
- "test/test_return_codes.rb",
80
- "test/test_source_file.rb",
81
- "test/test_source_file_line.rb"
82
- ]
83
-
84
- if s.respond_to? :specification_version then
85
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
86
- s.specification_version = 3
87
-
88
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
89
- s.add_runtime_dependency(%q<simplecov-html>, [">= 0.3.7"])
90
- s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
91
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
92
- s.add_development_dependency(%q<jeweler>, ["= 1.4.0"])
93
- else
94
- s.add_dependency(%q<simplecov-html>, [">= 0.3.7"])
95
- s.add_dependency(%q<shoulda>, ["= 2.10.3"])
96
- s.add_dependency(%q<rspec>, ["~> 2.0.0"])
97
- s.add_dependency(%q<jeweler>, ["= 1.4.0"])
98
- end
99
- else
100
- s.add_dependency(%q<simplecov-html>, [">= 0.3.7"])
101
- s.add_dependency(%q<shoulda>, ["= 2.10.3"])
102
- s.add_dependency(%q<rspec>, ["~> 2.0.0"])
103
- s.add_dependency(%q<jeweler>, ["= 1.4.0"])
104
- end
105
- end
15
+ s.rubyforge_project = "simplecov"
16
+
17
+ s.add_dependency 'simplecov-html', ">= 0.3.7"
18
+ s.add_development_dependency "shoulda", "2.10.3"
19
+ s.add_development_dependency "rspec", "~> 2.0.0"
106
20
 
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
data/test/helper.rb CHANGED
@@ -1,16 +1,21 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup(:default, :development)
2
+ require 'bundler/setup'
3
+ require 'simplecov'
4
+
4
5
  require 'test/unit'
5
6
  require 'shoulda'
6
7
 
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
- $LOAD_PATH.unshift(File.dirname(__FILE__))
9
- require 'simplecov'
10
8
  SimpleCov.coverage_dir('tmp/coverage')
11
9
 
12
10
  class Test::Unit::TestCase
13
11
  def source_fixture(filename)
14
12
  File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
15
13
  end
14
+
15
+ # Keep 1.8-rubies from complaining about missing tests in each file that covers only 1.9 functionality
16
+ def default_test
17
+ end
16
18
  end
19
+
20
+ require 'shoulda_macros'
21
+ Test::Unit::TestCase.send :extend, ShouldaMacros
@@ -0,0 +1,11 @@
1
+ module ShouldaMacros
2
+ #
3
+ # Simple block helper for running certain tests only on specific ruby versions.
4
+ # The given strings will be regexp-matched against RUBY_VERSION
5
+ #
6
+ def on_ruby(*ruby_versions)
7
+ context "On Ruby #{RUBY_VERSION}" do
8
+ yield
9
+ end if ruby_versions.any? {|v| RUBY_VERSION =~ /#{v}/ }
10
+ end
11
+ end