simplecov 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -8,24 +8,40 @@ In most cases, you'll want overall coverage results for your projects, including
8
8
  etc. Simplecov automatically takes care of this by caching and then merging results when generating reports, so your
9
9
  coverage report gives you a more accurate report on the blank spots in your test coverage.
10
10
 
11
- Though a very simple formatter for printing the coverage results comes bundled with the simplecov gem, this is more
12
- for explaining the basic usage of formatters if you want to build your own. To get a pretty HTML-page with your results,
13
- you will want to use the simplecov-html gem (http://github.com/colszowka/simplecov-html).
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
14
13
 
15
14
  == Basic usage
16
15
 
17
16
  Update your Gemfile with this and do a bundle install:
18
17
  group :test do
19
- gem 'simplecov-html', '>= 0.3.0' # Will install simplecov as a dependency
18
+ gem 'simplecov', '>= 0.3.2' # Will install simplecov-html as a dependency
20
19
  end
21
20
 
22
21
  Then, add the following to your Rails test/test_helper.rb (right at the top, line 00):
23
22
 
24
- require 'simplecov-html'
23
+ require 'simplecov'
25
24
  SimpleCov.start 'rails'
26
25
 
27
26
  Now, when running rake test you'll get a coverage/ folder inside your app's root where you can browse your code coverage.
28
27
 
28
+ == Example output
29
+
30
+ For the Devise Ruby gem (some tests were removed, they just have too awesome test coverage...)
31
+
32
+ http://img.skitch.com/20100823-n9f52i3ty3qa7cqj33rafghrtc.png
33
+
34
+ == Usage with Cucumber and RSpec (name your framework)
35
+
36
+ Similarily to the usage with Test::Unit described above, the only thing you have to do is to add the simplecov
37
+ config to the very top of your Cucumber/RSpec/whatever setup file.
38
+
39
+ Just add the setup snippet at the very(!) top of features/support/env.rb (for Cucumber) or spec/spec_helper.rb (for RSpec).
40
+ Other test frameworks should work accordingly.
41
+
42
+ require 'simplecov'
43
+ SimpleCov.start 'rails'
44
+
29
45
  == Configuration
30
46
 
31
47
  Configuration settings can be applied in three formats.
@@ -127,28 +143,29 @@ There are two things to note here though:
127
143
 
128
144
  === Test suite names
129
145
 
130
- First, simplecov by itself does not really know about "test suites" and thus makes a guess based upon the command
131
- line arguments it is currently running on. This works fine, though the test suites used for your coverage report
132
- won't be easy to recognize.
146
+ Simplecov tries to guess the name of the currently running test suite based upon the shell command the tests are running
147
+ on (from v0.3.2+). This should work fine for Unit Tests, RSpec and Cucumber. If it fails, it will use the shell command
148
+ that invoked the test suite as a command name.
133
149
 
134
- Thus, if you want nicely labeled test suites, you have to give Simplecov a cue what the name of the currently running
135
- test suite is. You can do so by specifying SimpleCov.command_name in one test file that is part of your specific suite.
150
+ If you have some non-standard setup and still want nicely labeled test suites, you have to give Simplecov a cue what the
151
+ name of the currently running test suite is. You can do so by specifying SimpleCov.command_name in one test file that is
152
+ part of your specific suite.
136
153
 
137
- So, in order to get proper suite names in a Rails app (yeah, sorry for being Rails biased, but everyone knows what
138
- the structure of those projects is. You can apply this accordingly to the RSpecs for your Outlook-WebDAV-Calendar-Sync gem),
154
+ So, to customize the suite names on a Rails app (yeah, sorry for being Rails biased, but everyone knows what
155
+ the structure of those projects is. You can apply this accordingly to the RSpecs in your Outlook-WebDAV-Calendar-Sync gem),
139
156
  you could do something like this:
140
157
 
141
158
  # test/unit/some_test.rb
142
- SimpleCov.command_name 'Unit Tests'
159
+ SimpleCov.command_name 'test:units'
143
160
 
144
161
  # test/functionals/some_controller_test.rb
145
- SimpleCov.command_name "Functional Tests"
162
+ SimpleCov.command_name "test:functionals"
146
163
 
147
164
  # test/integration/some_integration_test.rb
148
- SimpleCov.command_name "Integration Tests"
165
+ SimpleCov.command_name "test:integration"
149
166
 
150
167
  # features/steps/web_steps.rb
151
- SimpleCov.command_name "Cucumber Features"
168
+ SimpleCov.command_name "features"
152
169
 
153
170
  Note that this has only to be invoked ONCE PER TEST SUITE, so even if you have 200 unit test files, specifying it in
154
171
  some_test.rb is fair enough.
data/Rakefile CHANGED
@@ -5,11 +5,12 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "simplecov"
8
- gem.summary = %Q{Code coverage for Ruby 1.9}
9
- gem.description = %Q{Code coverage for Ruby 1.9}
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
10
  gem.email = "christoph at olszowka.de"
11
11
  gem.homepage = "http://github.com/colszowka/simplecov"
12
12
  gem.authors = ["Christoph Olszowka"]
13
+ gem.add_dependency 'simplecov-html', ">= 0.3.5"
13
14
  gem.add_development_dependency "shoulda", "= 2.10.3"
14
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
16
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
data/lib/simplecov.rb CHANGED
@@ -105,10 +105,12 @@ require 'simplecov/filter'
105
105
  require 'simplecov/formatter'
106
106
  require 'simplecov/merge_helpers'
107
107
  require 'simplecov/result_merger'
108
+ require 'simplecov/command_guesser'
109
+ require 'simplecov-html'
108
110
 
109
111
  # Default configuration
110
112
  SimpleCov.configure do
111
- formatter SimpleCov::Formatter::SimpleFormatter
113
+ formatter SimpleCov::Formatter::HTMLFormatter
112
114
  # Exclude files outside of SimpleCov.root
113
115
  load_adapter 'root_filter'
114
116
  end
@@ -37,6 +37,8 @@ end
37
37
 
38
38
  SimpleCov.adapters.define 'rails' do
39
39
  add_filter '/test/'
40
+ add_filter '/features/'
41
+ add_filter '/spec/'
40
42
  add_filter '/config/'
41
43
 
42
44
  add_group 'Controllers', 'app/controllers'
@@ -0,0 +1,21 @@
1
+ #
2
+ # Helper that tries to find out what test suite is running (for SimpleCov.command_name)
3
+ #
4
+ module SimpleCov::CommandGuesser
5
+ def self.guess(command)
6
+ case command
7
+ when /#{'test/functional/'}/
8
+ "Functional Tests"
9
+ when /#{'test/integration/'}/
10
+ "Integration Tests"
11
+ when /#{'test/'}/
12
+ "Unit Tests"
13
+ when /cucumber/, /features/
14
+ "Cucumber Features"
15
+ when /#{'spec/'}/
16
+ "RSpec"
17
+ else
18
+ return command
19
+ end
20
+ end
21
+ end
@@ -45,11 +45,19 @@ module SimpleCov::Configuration
45
45
  @filters ||= []
46
46
  end
47
47
 
48
- # The name of the command currently running. It is used for result merging and defaults
49
- # to the command line arguments the current test suite is running on.
50
- # You can specify it manually with SimpleCov.command_name("test:units")
48
+ # The name of the command (a.k.a. Test Suite) currently running. Used for result
49
+ # merging and caching. It first tries to make a guess based upon the command line
50
+ # arguments the current test suite is running on and should automatically detect
51
+ # unit tests, functional tests, integration tests, rpsec and cucumber and label
52
+ # them properly. If it fails to recognize the current command, the command name
53
+ # is set to the shell command that the current suite is running on.
54
+ #
55
+ # You can specify it manually with SimpleCov.command_name("test:units") - please
56
+ # also check out the corresponding section in README.rdoc
51
57
  def command_name(name=nil)
52
- @name ||= (name.nil? ? ARGV.join(" ") : name)
58
+ @name = name unless name.nil?
59
+ @name ||= SimpleCov::CommandGuesser.guess("#{$0} #{ARGV.join(" ")}")
60
+ @name
53
61
  end
54
62
 
55
63
  #
data/simplecov.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simplecov}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christoph Olszowka"]
12
- s.date = %q{2010-08-23}
13
- s.description = %q{Code coverage for Ruby 1.9}
12
+ s.date = %q{2010-08-25}
13
+ s.description = %q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
14
14
  s.email = %q{christoph at olszowka.de}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "lib/simplecov.rb",
27
27
  "lib/simplecov/adapters.rb",
28
+ "lib/simplecov/command_guesser.rb",
28
29
  "lib/simplecov/configuration.rb",
29
30
  "lib/simplecov/filter.rb",
30
31
  "lib/simplecov/formatter.rb",
@@ -33,7 +34,6 @@ Gem::Specification.new do |s|
33
34
  "lib/simplecov/result.rb",
34
35
  "lib/simplecov/result_merger.rb",
35
36
  "lib/simplecov/source_file.rb",
36
- "simple_cov.gemspec",
37
37
  "simplecov.gemspec",
38
38
  "test/fixtures/app/controllers/sample_controller.rb",
39
39
  "test/fixtures/app/models/user.rb",
@@ -41,6 +41,7 @@ Gem::Specification.new do |s|
41
41
  "test/fixtures/resultset2.rb",
42
42
  "test/fixtures/sample.rb",
43
43
  "test/helper.rb",
44
+ "test/test_command_guesser.rb",
44
45
  "test/test_filters.rb",
45
46
  "test/test_merge_helpers.rb",
46
47
  "test/test_result.rb",
@@ -51,7 +52,7 @@ Gem::Specification.new do |s|
51
52
  s.rdoc_options = ["--charset=UTF-8"]
52
53
  s.require_paths = ["lib"]
53
54
  s.rubygems_version = %q{1.3.7}
54
- s.summary = %q{Code coverage for Ruby 1.9}
55
+ s.summary = %q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
55
56
  s.test_files = [
56
57
  "test/fixtures/app/controllers/sample_controller.rb",
57
58
  "test/fixtures/app/models/user.rb",
@@ -59,6 +60,7 @@ Gem::Specification.new do |s|
59
60
  "test/fixtures/resultset2.rb",
60
61
  "test/fixtures/sample.rb",
61
62
  "test/helper.rb",
63
+ "test/test_command_guesser.rb",
62
64
  "test/test_filters.rb",
63
65
  "test/test_merge_helpers.rb",
64
66
  "test/test_result.rb",
@@ -71,11 +73,14 @@ Gem::Specification.new do |s|
71
73
  s.specification_version = 3
72
74
 
73
75
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
76
+ s.add_runtime_dependency(%q<simplecov-html>, [">= 0.3.5"])
74
77
  s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
75
78
  else
79
+ s.add_dependency(%q<simplecov-html>, [">= 0.3.5"])
76
80
  s.add_dependency(%q<shoulda>, ["= 2.10.3"])
77
81
  end
78
82
  else
83
+ s.add_dependency(%q<simplecov-html>, [">= 0.3.5"])
79
84
  s.add_dependency(%q<shoulda>, ["= 2.10.3"])
80
85
  end
81
86
  end
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ class TestCommandGuesser < Test::Unit::TestCase
4
+ def self.should_guess_command_name(expectation, *argv)
5
+ argv.each do |args|
6
+ should "return '#{expectation}' for '#{args}'" do
7
+ assert_equal expectation, SimpleCov::CommandGuesser.guess(args)
8
+ end
9
+ end
10
+ end
11
+
12
+ should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb'
13
+ should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb'
14
+ should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb'
15
+ should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features'
16
+ should_guess_command_name "RSpec", '/some/path/spec/foo.rb'
17
+ should_guess_command_name "some_arbitrary_command with arguments", 'some_arbitrary_command with arguments'
18
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Christoph Olszowka
@@ -14,13 +14,28 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-23 00:00:00 +02:00
17
+ date: 2010-08-25 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: shoulda
21
+ name: simplecov-html
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 3
31
+ - 5
32
+ version: 0.3.5
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: shoulda
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
24
39
  none: false
25
40
  requirements:
26
41
  - - "="
@@ -31,8 +46,8 @@ dependencies:
31
46
  - 3
32
47
  version: 2.10.3
33
48
  type: :development
34
- version_requirements: *id001
35
- description: Code coverage for Ruby 1.9
49
+ version_requirements: *id002
50
+ description: Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites
36
51
  email: christoph at olszowka.de
37
52
  executables: []
38
53
 
@@ -50,6 +65,7 @@ files:
50
65
  - VERSION
51
66
  - lib/simplecov.rb
52
67
  - lib/simplecov/adapters.rb
68
+ - lib/simplecov/command_guesser.rb
53
69
  - lib/simplecov/configuration.rb
54
70
  - lib/simplecov/filter.rb
55
71
  - lib/simplecov/formatter.rb
@@ -58,7 +74,6 @@ files:
58
74
  - lib/simplecov/result.rb
59
75
  - lib/simplecov/result_merger.rb
60
76
  - lib/simplecov/source_file.rb
61
- - simple_cov.gemspec
62
77
  - simplecov.gemspec
63
78
  - test/fixtures/app/controllers/sample_controller.rb
64
79
  - test/fixtures/app/models/user.rb
@@ -66,6 +81,7 @@ files:
66
81
  - test/fixtures/resultset2.rb
67
82
  - test/fixtures/sample.rb
68
83
  - test/helper.rb
84
+ - test/test_command_guesser.rb
69
85
  - test/test_filters.rb
70
86
  - test/test_merge_helpers.rb
71
87
  - test/test_result.rb
@@ -102,7 +118,7 @@ rubyforge_project:
102
118
  rubygems_version: 1.3.7
103
119
  signing_key:
104
120
  specification_version: 3
105
- summary: Code coverage for Ruby 1.9
121
+ summary: Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites
106
122
  test_files:
107
123
  - test/fixtures/app/controllers/sample_controller.rb
108
124
  - test/fixtures/app/models/user.rb
@@ -110,6 +126,7 @@ test_files:
110
126
  - test/fixtures/resultset2.rb
111
127
  - test/fixtures/sample.rb
112
128
  - test/helper.rb
129
+ - test/test_command_guesser.rb
113
130
  - test/test_filters.rb
114
131
  - test/test_merge_helpers.rb
115
132
  - test/test_result.rb
data/simple_cov.gemspec DELETED
@@ -1,81 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{simple_cov}
8
- s.version = "0.2.0"
9
-
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-08-20}
13
- s.description = %q{Makes ruby 1.9's code coverage library's results more accessible in an object-oriented manner and adds some sugar on top}
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
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/simple_cov.rb",
27
- "lib/simple_cov/adapters.rb",
28
- "lib/simple_cov/configuration.rb",
29
- "lib/simple_cov/filter.rb",
30
- "lib/simple_cov/formatter.rb",
31
- "lib/simple_cov/formatter/simple_formatter.rb",
32
- "lib/simple_cov/merge_helpers.rb",
33
- "lib/simple_cov/result.rb",
34
- "lib/simple_cov/result_merger.rb",
35
- "lib/simple_cov/source_file.rb",
36
- "simple_cov.gemspec",
37
- "test/fixtures/app/controllers/sample_controller.rb",
38
- "test/fixtures/app/models/user.rb",
39
- "test/fixtures/resultset1.rb",
40
- "test/fixtures/resultset2.rb",
41
- "test/fixtures/sample.rb",
42
- "test/helper.rb",
43
- "test/test_filters.rb",
44
- "test/test_merge_helpers.rb",
45
- "test/test_result.rb",
46
- "test/test_source_file.rb",
47
- "test/test_source_file_line.rb"
48
- ]
49
- s.homepage = %q{http://github.com/colszowka/simple_cov}
50
- s.rdoc_options = ["--charset=UTF-8"]
51
- s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.7}
53
- s.summary = %q{Makes ruby 1.9's code coverage library's results more accessible in an object-oriented manner and adds some sugar on top}
54
- s.test_files = [
55
- "test/fixtures/app/controllers/sample_controller.rb",
56
- "test/fixtures/app/models/user.rb",
57
- "test/fixtures/resultset1.rb",
58
- "test/fixtures/resultset2.rb",
59
- "test/fixtures/sample.rb",
60
- "test/helper.rb",
61
- "test/test_filters.rb",
62
- "test/test_merge_helpers.rb",
63
- "test/test_result.rb",
64
- "test/test_source_file.rb",
65
- "test/test_source_file_line.rb"
66
- ]
67
-
68
- if s.respond_to? :specification_version then
69
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
70
- s.specification_version = 3
71
-
72
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
73
- s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
74
- else
75
- s.add_dependency(%q<shoulda>, ["= 2.10.3"])
76
- end
77
- else
78
- s.add_dependency(%q<shoulda>, ["= 2.10.3"])
79
- end
80
- end
81
-