Created
April 11, 2015 03:36
-
-
Save Genki-S/cef9766b6ead493a2218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'coverage' | |
Coverage.start | |
require './a_method.rb' # => true | |
a_method | |
p Coverage.result # => {"/Users/.../a_method.rb"=>[1, 1, 1, 10, nil, 1, nil]} | |
# Does not produce coverage because `Coverage.result` clears out the coverage | |
# p Coverage.result # coverage measurement is not enabled (RuntimeError) | |
# Does not produce coverage because the file `a_method.rb` is not loaded | |
Coverage.start | |
a_method | |
p Coverage.result # => {"/Users/.../a_method.rb"=>[]} | |
# Does not produce coverage because the file `a_method.rb` is not loaded | |
Coverage.start | |
require './a_method.rb' # => false | |
a_method | |
p Coverage.result # => {"/Users/.../a_method.rb"=>[]} | |
# Unload `a_method.rb` | |
$".delete_if { |s| s.include?('a_method.rb') } | |
# Does produce coverage because the file `a_method.rb` is loaded | |
Coverage.start | |
require './a_method.rb' # => true | |
a_method | |
p Coverage.result # => {"/Users/.../a_method.rb"=>[1, 1, 1, 10, nil, 1, nil]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment