Skip to content

Commit

Permalink
Got the coverage reporting right
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Georg committed Feb 17, 2013
1 parent 2afe8a1 commit 3e81e56
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gemspec
group :development do
gem 'escape_utils', :platforms => [:mri_19, :mri_18]
gem 'coveralls', :require => false, :platforms => [:mri_19]
gem 'simplecov-console', :platforms => [:mri_19]
end

group :masochism do
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ GEM
adamantium (~> 0.0.5)
backports (~> 2.7.0)
escape_utils (0.2.4)
hirb (0.7.1)
ice_nine (0.6.0)
json (1.7.7)
mbj-inflector (0.0.2)
Expand Down Expand Up @@ -56,6 +57,10 @@ GEM
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
simplecov-console (0.1.1)
colorize
hirb
simplecov
simplecov-html (0.7.1)
thor (0.17.0)
to_source (0.2.18)
Expand All @@ -79,5 +84,6 @@ DEPENDENCIES
rake
redcarpet
rspec
simplecov-console
uri_template!
yard
5 changes: 5 additions & 0 deletions coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"result": {
"covered_percent": 97.81
}
}
10 changes: 5 additions & 5 deletions lib/uri_template/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#
# (c) 2011 - 2012 by Hannes Georg
#

module URITemplate

# An awesome little helper which helps iterating over a string.
Expand Down Expand Up @@ -132,11 +131,13 @@ def force_utf8(str)

end

# :nocov:
if "".respond_to?(:encode)
include Encode
else
include Fallback
end
# :nocov:

private :force_utf8

Expand Down Expand Up @@ -226,14 +227,15 @@ def unescape_uri(s)
end

include StringEncoding

# :nocov:
if Escaping.const_defined? :EscapeUtils
include Escaping::EscapeUtils
puts "Using escape_utils." if $VERBOSE
else
include Escaping::Pure
puts "Not using escape_utils." if $VERBOSE
end
# :nocov:

# Converts an object to a param value.
# Tries to call :to_param and then :to_s on that object.
Expand All @@ -260,9 +262,7 @@ def object_to_param(object)
# @api private
# Should we use \u.... or \x.. in regexps?
def use_unicode?
return eval('Regexp.compile("\u0020")') =~ " "
rescue SyntaxError
false
eval('Regexp.compile("\u0020")') =~ " " rescue false
end

# Returns true when the given value is an array and it only consists of arrays with two items.
Expand Down
17 changes: 12 additions & 5 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@
# (c) 2011 - 2012 by Hannes Georg
#

$LOAD_PATH << File.expand_path('../lib',File.dirname(__FILE__))

require 'bundler'
Bundler.setup(:default,:development)

if $0 !~ /mutant\z/
# using coverage in mutant is pointless
begin
require 'simplecov'
require 'simplecov-console'
require 'coveralls'
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.add_filter('/spec')
SimpleCov.start
# the console output needs this to work:
ROOT = File.expand_path('../lib',File.dirname(__FILE__))
SimpleCov.start do
add_filter '/spec'
formatter SimpleCov::Formatter::MultiFormatter[
Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::Console
]
refuse_coverage_drop
nocov_token "nocov"
end
rescue LoadError
warn 'Not using simplecov.'
end
Expand Down

0 comments on commit 3e81e56

Please sign in to comment.