Skip to content

Loading…

Minimal fix for warnings #119

Merged
merged 3 commits into from

2 participants

@mvz

These commits turn on warnings to demonstrate issue #106, and then fix the warnings emitted by rake test. I have attempted to keep the changes as minimal as possible; they basically boil down do inserting a defined? here and there.

Note: shoulda (or shoulda-context depending on which version is in your Gemfile.lock) will still emit some warnings during the running of the tests.

@colszowka colszowka merged commit f901802 into colszowka:master
@colszowka
Owner

Merged and will be part of the next release. Thanks for your effort! I'll add some further comment into #106

@jperkin jperkin pushed a commit to joyent/pkgsrc that referenced this pull request
taca Update ruby-simplecov to 0.6.4.
v0.6.4, 2012-05-10 ([changes](colszowka/simplecov@v0.6.3...v0.6.4))
-------------------

  * [BUGFIX] Encoding issues with ISO-8859-encoded source files fixed.
    See colszowka/simplecov#117. (thanks to @Deradon)
  * [BUGFIX] Ensure ZeroDivisionErrors won't occur when calculating the coverage result, which previously
    could happen in certain cases. See colszowka/simplecov#128. (thanks to @japgolly)
  * [REFACTORING] Changed a couple instance variable lookups so SimpleCov does not cause a lot of warnings when
    running ruby at a higher warning level. See colszowka/simplecov#106 and
    colszowka/simplecov#119. (thanks to @mvz and @gioele)


v0.6.3, 2012-05-10 ([changes](colszowka/simplecov@v0.6.2...v0.6.3))
-------------------

  * [BUGFIX] Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
    they are backwards-compatible with older multi_json gems in order to avoid simplecov polluting
    the multi_json minimum version requirement for entire applications.
    See colszowka/simplecov#132
  * Added appraisal gem to the test setup in order to run the test suite against both 1.0 and 1.3
    multi_json gems and ensure the above actually works :)
0410186
@jsonn jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request
taca Update ruby-simplecov to 0.6.4.
v0.6.4, 2012-05-10 ([changes](colszowka/simplecov@v0.6.3...v0.6.4))
-------------------

  * [BUGFIX] Encoding issues with ISO-8859-encoded source files fixed.
    See colszowka/simplecov#117. (thanks to @Deradon)
  * [BUGFIX] Ensure ZeroDivisionErrors won't occur when calculating the coverage result, which previously
    could happen in certain cases. See colszowka/simplecov#128. (thanks to @japgolly)
  * [REFACTORING] Changed a couple instance variable lookups so SimpleCov does not cause a lot of warnings when
    running ruby at a higher warning level. See colszowka/simplecov#106 and
    colszowka/simplecov#119. (thanks to @mvz and @gioele)


v0.6.3, 2012-05-10 ([changes](colszowka/simplecov@v0.6.2...v0.6.3))
-------------------

  * [BUGFIX] Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
    they are backwards-compatible with older multi_json gems in order to avoid simplecov polluting
    the multi_json minimum version requirement for entire applications.
    See colszowka/simplecov#132
  * Added appraisal gem to the test setup in order to run the test suite against both 1.0 and 1.3
    multi_json gems and ensure the above actually works :)
93cae9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 10 additions and 9 deletions.
  1. +1 −0 Rakefile
  2. +1 −1 lib/simplecov.rb
  3. +4 −4 lib/simplecov/configuration.rb
  4. +2 −2 lib/simplecov/result.rb
  5. +1 −1 lib/simplecov/source_file.rb
  6. +1 −1 test/test_source_file.rb
View
1 Rakefile
@@ -8,6 +8,7 @@ Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.test_files = FileList['test/test_*.rb']
test.verbose = true
+ test.warning = true
end
require 'cucumber/rake/task'
View
2 lib/simplecov.rb
@@ -48,7 +48,7 @@ def result
SimpleCov::ResultMerger.store_result(@result) if @result
return SimpleCov::ResultMerger.merged_result
else
- return @result
+ return @result if defined? @result
end
ensure
self.running = false
View
8 lib/simplecov/configuration.rb
@@ -14,7 +14,7 @@ module SimpleCov::Configuration
# Configure with SimpleCov.root('/my/project/path')
#
def root(root=nil)
- return @root if @root and root.nil?
+ return @root if defined? @root and root.nil?
@root = File.expand_path(root || Dir.getwd)
end
@@ -24,7 +24,7 @@ def root(root=nil)
# Configure with SimpleCov.coverage_dir('cov')
#
def coverage_dir(dir=nil)
- return @coverage_dir if @coverage_dir and dir.nil?
+ return @coverage_dir if defined? @coverage_dir and dir.nil?
@coverage_dir = (dir || 'coverage')
end
@@ -67,7 +67,7 @@ def command_name(name=nil)
# Configure with: SimpleCov.formatter(SimpleCov::Formatter::SimpleFormatter)
#
def formatter(formatter=nil)
- return @formatter if @formatter and formatter.nil?
+ return @formatter if defined? @formatter and formatter.nil?
@formatter = formatter
raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
@formatter
@@ -81,7 +81,7 @@ def formatter(formatter=nil)
# Configure with SimpleCov.nocov_token('skip') or it's alias SimpleCov.skip_token('skip')
#
def nocov_token(nocov_token=nil)
- return @nocov_token if @nocov_token and nocov_token.nil?
+ return @nocov_token if defined? @nocov_token and nocov_token.nil?
@nocov_token = (nocov_token || 'nocov')
end
alias_method :skip_token, :nocov_token
View
4 lib/simplecov/result.rb
@@ -58,7 +58,7 @@ def covered_strength
# Returns the count of lines that are covered
def covered_lines
- return @covered_lines if @covered_lines
+ return @covered_lines if defined? @covered_lines
@covered_lines = 0
@files.each do |file|
original_result[file.filename].each do |line_result|
@@ -70,7 +70,7 @@ def covered_lines
# Returns the count of missed lines
def missed_lines
- return @missed_lines if @missed_lines
+ return @missed_lines if defined? @missed_lines
@missed_lines = 0
@files.each do |file|
original_result[file.filename].each do |line_result|
View
2 lib/simplecov/source_file.rb
@@ -84,7 +84,7 @@ def initialize(filename, coverage)
# Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
# and thus including coverage data. Aliased as :source_lines
def lines
- return @lines unless @lines.nil?
+ return @lines if defined? @lines
# Warning to identify condition from Issue #56
if coverage.size > src.size
View
2 test/test_source_file.rb
@@ -68,7 +68,7 @@ class TestSourceFile < Test::Unit::TestCase
@source_file.lines
end
- assert_match /^Warning: coverage data provided/, captured_output
+ assert_match(/^Warning: coverage data provided/, captured_output)
end
end
Something went wrong with that request. Please try again.