simplecov 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 1.9.2
1
+ rvm use 1.9.3-p125
data/.travis.yml CHANGED
@@ -5,5 +5,9 @@ rvm:
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - ree
8
- # - rbx # Fails currently because of broken gemspec in Cucumber
9
- # - jruby # Has trouble installing on travis-ci right now
8
+ - rbx
9
+ - jruby
10
+ notifications:
11
+ email:
12
+ on_success: always
13
+ on_failure: always
data/CHANGELOG.md CHANGED
@@ -1,13 +1,29 @@
1
+ v0.6.0 (2012-02-22)
2
+ ===================
3
+
4
+ * [FEATURE] Auto-magic `rake simplecov` task for rails
5
+ (see https://github.com/colszowka/simplecov/pull/83, thanks @sunaku)
6
+ * [BUGFIX] Treat source files as UTF-8 to avoid encoding errors
7
+ (see https://github.com/colszowka/simplecov/pull/103, thanks @joeyates)
8
+ * [BUGFIX] Store the invoking terminal command right after loading so they are safe from
9
+ other libraries tampering with ARGV. Among other makes automatic Rails test suite splitting
10
+ (Unit/Functional/Integration) work with recent rake versions again
11
+ (see https://github.com/colszowka/simplecov/issues/110)
12
+ * [FEATURE] If guessing command name from the terminal command fails, try guessing from defined constants
13
+ (see https://github.com/colszowka/simplecov/commit/37afca54ef503c33d888e910f950b3b943cb9a6c)
14
+ * Some refactorings and cleanups as usual. Please refer to the github compare view for a full
15
+ list of changes: https://github.com/colszowka/simplecov/compare/v0.5.4...v0.6.0
16
+
1
17
  v0.5.4 (2011-10-12)
2
18
  ===================
3
19
 
4
- * Do not give exit code 0 when there are exceptions prior to tests
20
+ * Do not give exit code 0 when there are exceptions prior to tests
5
21
  (see https://github.com/colszowka/simplecov/issues/41, thanks @nbogie)
6
- * The API for building custom filter classes is now more obvious, using #matches? instead of #passes? too.
22
+ * The API for building custom filter classes is now more obvious, using #matches? instead of #passes? too.
7
23
  (see https://github.com/colszowka/simplecov/issues/85, thanks @robinroestenburg)
8
- * Mailers are now part of the Rails adapter as their own group (see
24
+ * Mailers are now part of the Rails adapter as their own group (see
9
25
  https://github.com/colszowka/simplecov/issues/79, thanks @geetarista)
10
- * Removed fix for JRuby 1.6 RC1 float bug because it's been fixed
26
+ * Removed fix for JRuby 1.6 RC1 float bug because it's been fixed
11
27
  (see https://github.com/colszowka/simplecov/issues/86)
12
28
  * Readme formatted in Markdown :)
13
29
 
@@ -17,10 +33,10 @@ v0.5.3 (2011-09-13)
17
33
  * Fix for encoding issues that came from the nocov processing mechanism
18
34
  (see https://github.com/colszowka/simplecov/issues/71)
19
35
  * :nocov: lines are now actually being reflected in the HTML report and are marked in yellow.
20
-
36
+
21
37
  * The Favicon in the HTML report is now determined by the overall coverage and will have the color
22
38
  that the coverage percentage gets as a css class to immediately indicate coverage status on first sight.
23
-
39
+
24
40
  * Introduced SimpleCov::SourceFile::Line#status method that returns the coverage status
25
41
  as a string for this line - made SimpleCov::HTML use that.
26
42
  * Refactored nocov processing and made it configurable using SimpleCov.ncov_token (or it's
@@ -38,9 +54,9 @@ v0.5.1 (2011-09-12)
38
54
 
39
55
  * Fix for invalid gemspec dependency string (see https://github.com/colszowka/simplecov/pull/70,
40
56
  http://blog.rubygems.org/2011/08/31/shaving-the-yaml-yacc.html, thanks @jspradlin)
41
-
57
+
42
58
  * Added JSON in the form of the multi_json gem as dependency for those cases when built-in JSON
43
- is unavailable (see https://github.com/colszowka/simplecov/issues/72
59
+ is unavailable (see https://github.com/colszowka/simplecov/issues/72
44
60
  and https://github.com/colszowka/simplecov/pull/74, thanks @sferik)
45
61
 
46
62
  v0.5.0 (2011-09-09)
data/README.md CHANGED
@@ -7,6 +7,7 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
7
7
  * [Changelog]
8
8
  * [Rubygem]
9
9
  * [Continuous Integration]
10
+ * IRC #simplecov on Freenode
10
11
 
11
12
  [Coverage]: http://www.ruby-doc.org/ruby-1.9/classes/Coverage.html "API doc for Ruby 1.9's Coverage library"
12
13
  [Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
@@ -36,7 +37,7 @@ Getting started
36
37
  ---------------
37
38
 
38
39
  1. Add SimpleCov to your `Gemfile` and `bundle install`:
39
-
40
+
40
41
  gem 'simplecov', :require => false, :group => :test
41
42
 
42
43
  2. Load and launch SimpleCov **at the very top** of your `test/test_helper.rb` (*or `spec_helper.rb`, cucumber `env.rb`, or whatever
@@ -46,21 +47,23 @@ Getting started
46
47
  SimpleCov.start
47
48
 
48
49
  # Previous content of test helper now starts here
49
-
50
- **Note:** If SimpleCov starts after your application code is already loaded (via `require`), it won't be able to track your files and their coverage!
50
+
51
+ **Note:** If SimpleCov starts after your application code is already loaded (via `require`), it won't be able to track your files and their coverage!
51
52
  The `SimpleCov.start` **must** be issued **before any of your application code is required!**
52
53
 
53
- 3. Run your tests, open up `coverage/index.html` in your browser and check out what you've missed so far.
54
+ 3. Run your tests, open up `coverage/index.html` in your browser and check out what you've missed so far.
55
+
56
+ 4. Add the following to your `.gitignore` file to ensure that coverage results are not tracked by Git (optional):
57
+
58
+ coverage
54
59
 
55
60
  If you're making a Rails application, SimpleCov comes with a built-in adapter (see below for more information on what adapters are)
56
- which will get you started with groups for your Controllers, Views, Models and Helpers. To use it, the first two lines of
61
+ which will get you started with groups for your Controllers, Views, Models and Helpers. To use it, the first two lines of
57
62
  your test_helper should be like this:
58
63
 
59
64
  require 'simplecov'
60
65
  SimpleCov.start 'rails'
61
66
 
62
-
63
-
64
67
  ## Example output
65
68
 
66
69
  **Coverage results report, fully browsable locally with sorting and much more:**
@@ -88,7 +91,65 @@ Other test frameworks should work accordingly, whatever their setup file may be:
88
91
  You could even track what kind of code your UI testers are touching if you want to go overboard with things. SimpleCov does not
89
92
  care what kind of framework it is running in, it just looks at what code is being executed and generates a report about it.
90
93
 
91
-
94
+ ### Notes on specific frameworks and test utilities
95
+
96
+ For some frameworks and testing tools there are quirks and problems you might want to know about if you want
97
+ to use SimpleCov with them. Here's an overview of the known ones:
98
+
99
+ <table>
100
+ <tr><th>Framework</th><th>Notes</th><th>Issue #</th></tr>
101
+ <tr>
102
+ <td>
103
+ <b>Test/Unit 2</b>
104
+ </td>
105
+ <td>
106
+ Test Unit 2 used to mess with ARGV, leading to failure to detect the test process name in SimpleCov.
107
+ <code>test-unit</code> releases 2.4.3+ (Dec 11th, 2011) should have this problem resolved.
108
+ </td>
109
+ <td>
110
+ <a href="https://github.com/colszowka/simplecov/issues/45">SimpleCov #45</a> &
111
+ <a href="https://github.com/test-unit/test-unit/pull/12">Test/Unit #12</a>
112
+ </td>
113
+ </tr>
114
+ <tr>
115
+ <td>
116
+ <b>Spork</b>
117
+ </td>
118
+ <td>
119
+ SimpleCov currently does not correctly cope with the way Spork (and similar forking testing tools)
120
+ works. With the right configuration this might be resolvable.
121
+ To make sure your coverage is reported correctly you probably should fall back to running your test suite
122
+ without spork when you want a coverage report.
123
+ </td>
124
+ <td>
125
+ <a href="https://github.com/colszowka/simplecov/issues/42">SimpleCov #42</a>
126
+ </td>
127
+ </tr>
128
+ <tr>
129
+ <td>
130
+ <b>parallel_tests</b>
131
+ </td>
132
+ <td>
133
+ SimpleCov does not detect parallel_test automatically yet but can be taught to do so
134
+ with a simple workaround explained at Issue #64.
135
+ </td>
136
+ <td>
137
+ <a href="https://github.com/colszowka/simplecov/issues/64">SimpleCov #64</a>
138
+ </td>
139
+ </tr>
140
+ <tr>
141
+ <td>
142
+ <b>Riot</b>
143
+ </td>
144
+ <td>
145
+ A user has reported problems with the coverage report using the riot framework. If you experience
146
+ similar trouble please follow up on the related Github issue.
147
+ </td>
148
+ <td>
149
+ <a href="https://github.com/colszowka/simplecov/issues/80">SimpleCov #80</a>
150
+ </td>
151
+ </tr>
152
+ </table>
92
153
 
93
154
  ## Configuring SimpleCov
94
155
 
@@ -109,7 +170,7 @@ care what kind of framework it is running in, it just looks at what code is bein
109
170
  SimpleCov.configure do
110
171
  some_config_option 'foo'
111
172
  end
112
-
173
+
113
174
  Please check out the [Configuration] API documentation to find out what you can customize.
114
175
 
115
176
 
@@ -123,10 +184,10 @@ test setup helper and move the `SimpleCov.start` code with all your custom confi
123
184
 
124
185
  # test/test_helper.rb
125
186
  require 'simplecov'
126
-
187
+
127
188
  # features/support/env.rb
128
189
  require 'simplecov'
129
-
190
+
130
191
  # .simplecov
131
192
  SimpleCov.start 'rails' do
132
193
  # any custom configs like groups and filters can be here at a central place
@@ -379,8 +440,8 @@ CSV formatter for SimpleCov code coverage tool for ruby 1.9+
379
440
  [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)](http://travis-ci.org/colszowka/simplecov)
380
441
 
381
442
  Only Ruby 1.9+ ships with the coverage library that SimpleCov depends upon. SimpleCov is built against various other Rubies,
382
- including Rubinius and JRuby, in [Continuous Integration], but this happens only to ensure that SimpleCov does not make your
383
- test suite crash right now. Whether SimpleCov will support JRuby/Rubinius in the future depends solely on whether those Ruby
443
+ including Rubinius and JRuby, in [Continuous Integration], but this happens only to ensure that SimpleCov does not make your
444
+ test suite crash right now. Whether SimpleCov will support JRuby/Rubinius in the future depends solely on whether those Ruby
384
445
  interpreters add the coverage library.
385
446
 
386
447
  SimpleCov is built in [Continuous Integration] on 1.8.7, ree, 1.9.2, 1.9.3.
@@ -407,8 +468,8 @@ If you wont to contribute, please:
407
468
 
408
469
  Thanks to Aaron Patterson (http://engineering.attinteractive.com/2010/08/code-coverage-in-ruby-1-9/) for the original idea
409
470
  for this!
410
-
471
+
411
472
 
412
473
  ## Copyright
413
474
 
414
- Copyright (c) 2010-2011 Christoph Olszowka. See LICENSE for details.
475
+ Copyright (c) 2010-2012 Christoph Olszowka. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env rake
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
@@ -8,7 +10,7 @@ Rake::TestTask.new(:test) do |test|
8
10
  test.verbose = true
9
11
  end
10
12
 
11
- task :default => :test
12
-
13
13
  require 'cucumber/rake/task'
14
14
  Cucumber::Rake::Task.new
15
+
16
+ task :default => [:test, :cucumber]
@@ -3,7 +3,7 @@ Feature:
3
3
 
4
4
  Code wrapped in # :nocov: will be ignored by coverage reports.
5
5
  The name of the token can be configured with SimpleCov.nocov_token or SimpleCov.skip_token
6
-
6
+
7
7
  Scenario: Custom nocov token using nocov_token
8
8
  Given SimpleCov for Test/Unit is configured with:
9
9
  """
@@ -12,7 +12,7 @@ Feature:
12
12
  nocov_token 'skippit'
13
13
  end
14
14
  """
15
-
15
+
16
16
  Given a file named "lib/faked_project/nocov.rb" with:
17
17
  """
18
18
  class SourceCodeWithNocov
@@ -40,7 +40,7 @@ Feature:
40
40
 
41
41
  And the report should be based upon:
42
42
  | Unit Tests |
43
-
43
+
44
44
  Scenario: Custom nocov token using skip_token
45
45
  Given SimpleCov for Test/Unit is configured with:
46
46
  """
@@ -76,4 +76,4 @@ Feature:
76
76
  And there should be 5 skipped lines in the source files
77
77
 
78
78
  And the report should be based upon:
79
- | Unit Tests |
79
+ | Unit Tests |
@@ -2,9 +2,9 @@
2
2
  Feature: Grouping on RSpec using a custom filter class
3
3
 
4
4
  Next to passing a block or a string to define a group, you can also pass
5
- a filter class. The filter class inherits from SimpleCov::Filter and
6
- must implement the matches? method, which is used to determine whether
7
- or not a file should be added to the group.
5
+ a filter class. The filter class inherits from SimpleCov::Filter and
6
+ must implement the matches? method, which is used to determine whether
7
+ or not a file should be added to the group.
8
8
 
9
9
  Scenario:
10
10
  Given SimpleCov for RSpec is configured with:
@@ -31,7 +31,7 @@ Feature: Grouping on RSpec using a custom filter class
31
31
 
32
32
  And I should see the source files:
33
33
  | name | coverage |
34
- | lib/faked_project/framework_specific.rb | 75.0 % |
34
+ | lib/faked_project/framework_specific.rb | 75.0 % |
35
35
  | lib/faked_project/some_class.rb | 80.0 % |
36
36
  | lib/faked_project.rb | 100.0 % |
37
37
  | lib/faked_project/meta_magic.rb | 100.0 % |
@@ -3,7 +3,7 @@ Feature:
3
3
 
4
4
  When code is wrapped in :nocov: comment blocks, it does not count
5
5
  against the coverage numbers.
6
-
6
+
7
7
  Background:
8
8
  Given SimpleCov for Test/Unit is configured with:
9
9
  """
@@ -34,12 +34,12 @@ Feature:
34
34
  | lib/faked_project/framework_specific.rb | 75.0 % |
35
35
  | lib/faked_project/meta_magic.rb | 100.0 % |
36
36
  | lib/faked_project/nocov.rb | 100.0 % |
37
-
37
+
38
38
  And there should be 5 skipped lines in the source files
39
39
 
40
40
  And the report should be based upon:
41
41
  | Unit Tests |
42
-
42
+
43
43
  Scenario: Number of spaces should not mix up nocov results
44
44
  Given a file named "lib/faked_project/nocov.rb" with:
45
45
  """
@@ -67,4 +67,4 @@ Feature:
67
67
  And there should be 5 skipped lines in the source files
68
68
 
69
69
  And the report should be based upon:
70
- | Unit Tests |
70
+ | Unit Tests |
@@ -42,4 +42,4 @@ end
42
42
 
43
43
  Then /^there should be (\d+) skipped lines in the source files$/ do |expected_count|
44
44
  all(".source_table ol li.skipped").count.should == expected_count.to_i
45
- end
45
+ end
@@ -12,7 +12,7 @@ Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
12
12
  else
13
13
  raise ArgumentError, "Could not identify test framework #{framework}!"
14
14
  end
15
-
15
+
16
16
  steps %Q{
17
17
  Given a file named "#{framework_dir}/simplecov_config.rb" with:
18
18
  """
@@ -22,5 +22,5 @@ Before do
22
22
  FileUtils.rm_rf 'project'
23
23
  FileUtils.cp_r File.join(this_dir, '../../test/faked_project/'), 'project'
24
24
  end
25
- Given 'I cd to "project"'
25
+ step 'I cd to "project"'
26
26
  end
@@ -2,9 +2,9 @@
2
2
  Feature: Grouping on Test/Unit using a custom filter class
3
3
 
4
4
  Next to passing a block or a string to define a group, you can also pass
5
- a filter class. The filter class inherits from SimpleCov::Filter and
6
- must implement the matches? method, which is used to determine whether
7
- or not a file should be added to the group.
5
+ a filter class. The filter class inherits from SimpleCov::Filter and
6
+ must implement the matches? method, which is used to determine whether
7
+ or not a file should be added to the group.
8
8
 
9
9
  Scenario:
10
10
  Given SimpleCov for Test/Unit is configured with:
@@ -31,7 +31,7 @@ Feature: Grouping on Test/Unit using a custom filter class
31
31
 
32
32
  And I should see the source files:
33
33
  | name | coverage |
34
- | lib/faked_project/framework_specific.rb | 75.0 % |
34
+ | lib/faked_project/framework_specific.rb | 75.0 % |
35
35
  | lib/faked_project/some_class.rb | 80.0 % |
36
36
  | lib/faked_project.rb | 100.0 % |
37
37
  | lib/faked_project/meta_magic.rb | 100.0 % |
@@ -3,7 +3,7 @@ Feature:
3
3
 
4
4
  Files with unicode in their source should be no problem at all for
5
5
  generating a proper coverage report.
6
-
6
+
7
7
  Background:
8
8
  Given SimpleCov for Test/Unit is configured with:
9
9
  """
data/lib/simplecov.rb CHANGED
@@ -118,3 +118,6 @@ require 'simplecov/version'
118
118
 
119
119
  # Load default config
120
120
  require 'simplecov/defaults'
121
+
122
+ # Load Rails integration
123
+ require 'simplecov/railtie' if defined? Rails
@@ -2,20 +2,48 @@
2
2
  # Helper that tries to find out what test suite is running (for SimpleCov.command_name)
3
3
  #
4
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/
5
+ class << self
6
+ # Storage for the original command line call that invoked the test suite.
7
+ # This has got to be stored as early as possible because i.e. rake and test/unit 2
8
+ # have a habit of tampering with ARGV, which makes i.e. the automatic distinction
9
+ # between rails unit/functional/integration tests impossible without this cached
10
+ # item.
11
+ attr_accessor :original_run_command
12
+
13
+ def guess
14
+ from_command_line_options || from_defined_constants
15
+ end
16
+
17
+ private
18
+
19
+ def from_command_line_options
20
+ case original_run_command
21
+ when /#{'test/functional/'}/
22
+ "Functional Tests"
23
+ when /#{'test/integration/'}/
24
+ "Integration Tests"
25
+ when /#{'test/'}/
26
+ "Unit Tests"
27
+ when /cucumber/, /features/
28
+ "Cucumber Features"
29
+ when /spec/
30
+ "RSpec"
31
+ else
32
+ nil
33
+ end
34
+ end
35
+
36
+ def from_defined_constants
37
+ # If the command regexps fail, let's try checking defined constants.
38
+ if defined?(RSpec)
16
39
  "RSpec"
40
+ elsif defined?(Test::Unit)
41
+ "Unit Tests"
17
42
  else
18
- return command
43
+ # TODO: Provide link to docs/wiki article
44
+ warn "SimpleCov failed to recognize the test framework and/or suite used. Please specify manually using SimpleCov.command_name 'Unit Tests'."
45
+ 'Unknown Test Framework'
46
+ end
19
47
  end
20
48
  end
21
- end
49
+ end
@@ -57,10 +57,10 @@ module SimpleCov::Configuration
57
57
  # also check out the corresponding section in README.rdoc
58
58
  def command_name(name=nil)
59
59
  @name = name unless name.nil?
60
- @name ||= SimpleCov::CommandGuesser.guess("#{$0} #{ARGV.join(" ")}")
60
+ @name ||= SimpleCov::CommandGuesser.guess
61
61
  @name
62
62
  end
63
-
63
+
64
64
  #
65
65
  # Gets or sets the configured formatter.
66
66
  #
@@ -72,9 +72,9 @@ module SimpleCov::Configuration
72
72
  raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
73
73
  @formatter
74
74
  end
75
-
75
+
76
76
  #
77
- # Certain code blocks (i.e. Ruby-implementation specific code) can be excluded from
77
+ # Certain code blocks (i.e. Ruby-implementation specific code) can be excluded from
78
78
  # the coverage metrics by wrapping it inside # :nocov: comment blocks. The nocov token
79
79
  # can be configured to be any other string using this.
80
80
  #
@@ -195,6 +195,8 @@ module SimpleCov::Configuration
195
195
  def add_group(group_name, filter_argument=nil, &filter_proc)
196
196
  groups[group_name] = parse_filter(filter_argument, &filter_proc)
197
197
  end
198
+
199
+ private
198
200
 
199
201
  #
200
202
  # The actal filter processor. Not meant for direct use
@@ -36,6 +36,10 @@ SimpleCov.configure do
36
36
  # Exclude files outside of SimpleCov.root
37
37
  load_adapter 'root_filter'
38
38
  end
39
+
40
+ # Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
41
+ SimpleCov::CommandGuesser.original_run_command = "#{$0} #{ARGV.join(" ")}"
42
+
39
43
  at_exit do
40
44
  # Store the exit status of the test run since it goes away after calling the at_exit proc...
41
45
  if $! #was an exception thrown?
@@ -50,4 +54,4 @@ end
50
54
 
51
55
  # Autoload config from .simplecov if present
52
56
  config_path = File.join(SimpleCov.root, '.simplecov')
53
- load config_path if File.exist?(config_path)
57
+ load config_path if File.exist?(config_path)
@@ -19,7 +19,7 @@ module SimpleCov
19
19
  def matches?(source_file)
20
20
  raise "The base filter class is not intended for direct use"
21
21
  end
22
-
22
+
23
23
  def passes?(source_file)
24
24
  warn "DEPRECATION: SimpleCov::Filter#passes?(x) has been renamed to #matches?. Please update your custom filters accordingly!"
25
25
  matches?(source_file)
@@ -0,0 +1,7 @@
1
+ module SimpleCov
2
+ class Railtie < ::Rails::Railtie
3
+ rake_tasks do
4
+ load 'simplecov/railties/tasks.rake'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'rake/testtask'
2
+ Rake::TestTask.new do |t|
3
+ t.name = 'simplecov'
4
+ t.loader = :direct # uses require() which skips PWD in Ruby 1.9
5
+ t.libs.push 'test', 'spec', Dir.pwd
6
+ t.test_files = FileList['{test,spec}/**/*_{test,spec}.rb']
7
+ t.ruby_opts.push '-r', 'simplecov', '-e', 'SimpleCov.start(:rails)'.inspect
8
+ end
9
+
10
+ require 'rake/clean'
11
+ CLOBBER.include 'coverage'
@@ -44,7 +44,7 @@ module SimpleCov
44
44
 
45
45
  # The multiple of coverage for this result
46
46
  def covered_strength
47
- return @covered_strength if @convered_strength
47
+ return @covered_strength if @covered_strength
48
48
  m = 0
49
49
  @files.each do |file|
50
50
  original_result[file.filename].each do |line_result|
@@ -46,7 +46,7 @@ module SimpleCov
46
46
  def never?
47
47
  not skipped? and coverage.nil?
48
48
  end
49
-
49
+
50
50
  # Flags this line as skipped
51
51
  def skipped!
52
52
  @skipped = true
@@ -57,8 +57,8 @@ module SimpleCov
57
57
  def skipped?
58
58
  !!skipped
59
59
  end
60
-
61
- # The status of this line - either covered, missed, skipped or never. Useful i.e. for direct use
60
+
61
+ # The status of this line - either covered, missed, skipped or never. Useful i.e. for direct use
62
62
  # as a css class in report generation
63
63
  def status
64
64
  return 'skipped' if skipped?
@@ -77,7 +77,8 @@ module SimpleCov
77
77
  alias_method :source, :src
78
78
 
79
79
  def initialize(filename, coverage)
80
- @filename, @coverage, @src = filename, coverage, File.readlines(filename)
80
+ @filename, @coverage = filename, coverage
81
+ File.open(filename, "r:UTF-8") {|f| @src = f.readlines }
81
82
  end
82
83
 
83
84
  # Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
@@ -1,3 +1,3 @@
1
1
  module SimpleCov
2
- VERSION = "0.5.4"
3
- end
2
+ VERSION = "0.6.0"
3
+ end
data/simplecov.gemspec CHANGED
@@ -12,14 +12,14 @@ Gem::Specification.new do |gem|
12
12
  gem.description = %Q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
13
13
  gem.summary = gem.description
14
14
 
15
- gem.add_dependency 'multi_json', '~> 1.0.3'
15
+ gem.add_dependency 'multi_json', '~> 1.0'
16
16
  gem.add_dependency 'simplecov-html', '~> 0.5.3'
17
- gem.add_development_dependency 'aruba', '~> 0.4'
18
- gem.add_development_dependency 'capybara', '~> 1.0'
19
- gem.add_development_dependency 'cucumber', '~> 1.0.5'
20
- gem.add_development_dependency 'rake', '~> 0.8'
21
- gem.add_development_dependency 'rspec', '~> 2.6'
22
- gem.add_development_dependency 'shoulda', '~> 2.10'
17
+ gem.add_development_dependency 'aruba'
18
+ gem.add_development_dependency 'capybara'
19
+ gem.add_development_dependency 'cucumber', '>= 1.1.4'
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'shoulda'
23
23
 
24
24
  gem.files = `git ls-files`.split("\n")
25
25
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -8,4 +8,4 @@ Dir[File.join(File.dirname(__FILE__), 'faked_project/*.rb')].each do |file|
8
8
  require file # Require all source files in project dynamically so we can inject some stuff depending on test situation
9
9
  end
10
10
 
11
- FakedProject.send :include, MetaMagic
11
+ FakedProject.send :include, MetaMagic
@@ -1,6 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..'))
2
2
  require 'lib/simplecov'
3
- SimpleCov.start
3
+ SimpleCov.start { command_name "Test" }
4
4
 
5
5
  dir = File.expand_path(File.dirname(__FILE__))
6
6
  file = File.join(dir, "generated_buddha.rb")
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ puts '135°C'
data/test/helper.rb CHANGED
@@ -13,7 +13,7 @@ class Test::Unit::TestCase
13
13
  # Keep 1.8-rubies from complaining about missing tests in each file that covers only 1.9 functionality
14
14
  def default_test
15
15
  end
16
-
16
+
17
17
  end
18
18
 
19
19
  require 'shoulda_macros'
@@ -8,19 +8,19 @@ module ShouldaMacros
8
8
  yield
9
9
  end if ruby_versions.any? {|v| RUBY_VERSION =~ /#{v}/ }
10
10
  end
11
-
11
+
12
12
  def should_be(boolean_flag)
13
13
  should "be #{boolean_flag}" do
14
14
  assert_equal true, subject.send(boolean_flag)
15
15
  end
16
16
  end
17
-
17
+
18
18
  def should_not_be(boolean_flag)
19
19
  should "not be #{boolean_flag}" do
20
20
  assert_equal false, subject.send(boolean_flag)
21
21
  end
22
22
  end
23
-
23
+
24
24
  def should_have(attr_name, expectation)
25
25
  should "have #{attr_name} == #{expectation.inspect}" do
26
26
  assert_equal expectation, subject.send(attr_name)
@@ -5,7 +5,8 @@ class TestCommandGuesser < Test::Unit::TestCase
5
5
  def self.should_guess_command_name(expectation, *argv)
6
6
  argv.each do |args|
7
7
  should "return '#{expectation}' for '#{args}'" do
8
- assert_equal expectation, SimpleCov::CommandGuesser.guess(args)
8
+ SimpleCov::CommandGuesser.original_run_command = args
9
+ assert_equal expectation, SimpleCov::CommandGuesser.guess
9
10
  end
10
11
  end
11
12
  end
@@ -15,6 +16,6 @@ class TestCommandGuesser < Test::Unit::TestCase
15
16
  should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb'
16
17
  should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features'
17
18
  should_guess_command_name "RSpec", '/some/path/spec/foo.rb'
18
- should_guess_command_name "some_arbitrary_command with arguments", 'some_arbitrary_command with arguments'
19
+ should_guess_command_name "Unit Tests", 'some_arbitrary_command with arguments' # Because Test::Unit const is defined!
19
20
  end
20
21
  end
@@ -71,5 +71,16 @@ class TestSourceFile < Test::Unit::TestCase
71
71
  assert_match /^Warning: coverage data provided/, captured_output
72
72
  end
73
73
  end
74
+
75
+ context "Encoding" do
76
+ should "handle utf-8 encoded source files" do
77
+ source_file = SimpleCov::SourceFile.new(source_fixture('utf-8.rb'), [nil, nil, 1])
78
+
79
+ assert_nothing_raised do
80
+ source_file.process_skipped_lines!
81
+ end
82
+ end
83
+ end
84
+
74
85
  end
75
86
  end
@@ -2,7 +2,7 @@ require 'helper'
2
2
 
3
3
  class TestSourceFileLine < Test::Unit::TestCase
4
4
 
5
-
5
+
6
6
  on_ruby '1.9' do
7
7
  context "A source line" do
8
8
  setup do
@@ -26,10 +26,10 @@ class TestSourceFileLine < Test::Unit::TestCase
26
26
  assert_equal @line.line_number, @line.line
27
27
  assert_equal @line.line_number, @line.number
28
28
  end
29
-
29
+
30
30
  context "flagged as skipped!" do
31
31
  setup { @line.skipped! }
32
-
32
+
33
33
  should_not_be :covered?
34
34
  should_be :skipped?
35
35
  should_not_be :missed?
@@ -37,7 +37,7 @@ class TestSourceFileLine < Test::Unit::TestCase
37
37
  should_have :status, 'skipped'
38
38
  end
39
39
  end
40
-
40
+
41
41
  context "A source line with coverage" do
42
42
  setup do
43
43
  @line = SimpleCov::SourceFile::Line.new('# the ruby source', 5, 3)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,23 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-12 00:00:00.000000000 +02:00
13
- default_executable:
12
+ date: 2012-02-22 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: multi_json
17
- requirement: &70223996324480 !ruby/object:Gem::Requirement
16
+ requirement: &70340785954640 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
21
20
  - !ruby/object:Gem::Version
22
- version: 1.0.3
21
+ version: '1.0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *70223996324480
24
+ version_requirements: *70340785954640
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: simplecov-html
28
- requirement: &70223996323980 !ruby/object:Gem::Requirement
27
+ requirement: &70340785954140 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
@@ -33,73 +32,73 @@ dependencies:
33
32
  version: 0.5.3
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *70223996323980
35
+ version_requirements: *70340785954140
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: aruba
39
- requirement: &70223996323380 !ruby/object:Gem::Requirement
38
+ requirement: &70340785953760 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
- - - ~>
41
+ - - ! '>='
43
42
  - !ruby/object:Gem::Version
44
- version: '0.4'
43
+ version: '0'
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *70223996323380
46
+ version_requirements: *70340785953760
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: capybara
50
- requirement: &70223996322760 !ruby/object:Gem::Requirement
49
+ requirement: &70340785953300 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
- - - ~>
52
+ - - ! '>='
54
53
  - !ruby/object:Gem::Version
55
- version: '1.0'
54
+ version: '0'
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *70223996322760
57
+ version_requirements: *70340785953300
59
58
  - !ruby/object:Gem::Dependency
60
59
  name: cucumber
61
- requirement: &70223996322160 !ruby/object:Gem::Requirement
60
+ requirement: &70340785952800 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
- - - ~>
63
+ - - ! '>='
65
64
  - !ruby/object:Gem::Version
66
- version: 1.0.5
65
+ version: 1.1.4
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *70223996322160
68
+ version_requirements: *70340785952800
70
69
  - !ruby/object:Gem::Dependency
71
70
  name: rake
72
- requirement: &70223996321600 !ruby/object:Gem::Requirement
71
+ requirement: &70340785952380 !ruby/object:Gem::Requirement
73
72
  none: false
74
73
  requirements:
75
- - - ~>
74
+ - - ! '>='
76
75
  - !ruby/object:Gem::Version
77
- version: '0.8'
76
+ version: '0'
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *70223996321600
79
+ version_requirements: *70340785952380
81
80
  - !ruby/object:Gem::Dependency
82
81
  name: rspec
83
- requirement: &70223996321120 !ruby/object:Gem::Requirement
82
+ requirement: &70340785951920 !ruby/object:Gem::Requirement
84
83
  none: false
85
84
  requirements:
86
- - - ~>
85
+ - - ! '>='
87
86
  - !ruby/object:Gem::Version
88
- version: '2.6'
87
+ version: '0'
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *70223996321120
90
+ version_requirements: *70340785951920
92
91
  - !ruby/object:Gem::Dependency
93
92
  name: shoulda
94
- requirement: &70223996320600 !ruby/object:Gem::Requirement
93
+ requirement: &70340785951500 !ruby/object:Gem::Requirement
95
94
  none: false
96
95
  requirements:
97
- - - ~>
96
+ - - ! '>='
98
97
  - !ruby/object:Gem::Version
99
- version: '2.10'
98
+ version: '0'
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *70223996320600
101
+ version_requirements: *70340785951500
103
102
  description: Code coverage for Ruby 1.9 with a powerful configuration library and
104
103
  automatic merging of coverage across test suites
105
104
  email:
@@ -156,6 +155,8 @@ files:
156
155
  - lib/simplecov/formatter.rb
157
156
  - lib/simplecov/formatter/simple_formatter.rb
158
157
  - lib/simplecov/merge_helpers.rb
158
+ - lib/simplecov/railtie.rb
159
+ - lib/simplecov/railties/tasks.rake
159
160
  - lib/simplecov/result.rb
160
161
  - lib/simplecov/result_merger.rb
161
162
  - lib/simplecov/source_file.rb
@@ -189,6 +190,7 @@ files:
189
190
  - test/fixtures/resultset1.rb
190
191
  - test/fixtures/resultset2.rb
191
192
  - test/fixtures/sample.rb
193
+ - test/fixtures/utf-8.rb
192
194
  - test/helper.rb
193
195
  - test/shoulda_macros.rb
194
196
  - test/test_1_8_fallbacks.rb
@@ -201,7 +203,6 @@ files:
201
203
  - test/test_return_codes.rb
202
204
  - test/test_source_file.rb
203
205
  - test/test_source_file_line.rb
204
- has_rdoc: true
205
206
  homepage: http://github.com/colszowka/simplecov
206
207
  licenses: []
207
208
  post_install_message:
@@ -222,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
223
  version: '0'
223
224
  requirements: []
224
225
  rubyforge_project:
225
- rubygems_version: 1.6.2
226
+ rubygems_version: 1.8.16
226
227
  signing_key:
227
228
  specification_version: 3
228
229
  summary: Code coverage for Ruby 1.9 with a powerful configuration library and automatic
@@ -285,6 +286,7 @@ test_files:
285
286
  - test/fixtures/resultset1.rb
286
287
  - test/fixtures/resultset2.rb
287
288
  - test/fixtures/sample.rb
289
+ - test/fixtures/utf-8.rb
288
290
  - test/helper.rb
289
291
  - test/shoulda_macros.rb
290
292
  - test/test_1_8_fallbacks.rb
@@ -297,3 +299,4 @@ test_files:
297
299
  - test/test_return_codes.rb
298
300
  - test/test_source_file.rb
299
301
  - test/test_source_file_line.rb
302
+ has_rdoc: