summaryrefslogtreecommitdiff
path: root/test/coverage
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 16:12:52 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 16:12:52 +0000
commit1d147fb24ca9c76c93c9bc449909364ac9a13b30 (patch)
tree5daf2007aef3b91583b84aa54bdf4dbb1c566cad /test/coverage
parent7023a64d802487c2fa0c2de574d6093d2fe0be25 (diff)
* test/coverage/test_coverage.rb: add a test for restart. a patch
from Xavier Shay. [ruby-core:36745] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage')
-rw-r--r--test/coverage/test_coverage.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index ace49d3..56966b1 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -1,5 +1,6 @@
require "test/unit"
require "coverage"
+require "tmpdir"
class TestCoverage < Test::Unit::TestCase
def test_result_without_start
@@ -14,4 +15,29 @@ class TestCoverage < Test::Unit::TestCase
assert_kind_of(Array, val)
end
end
+
+ def test_restarting_coverage
+ loaded_features = $".dup
+
+ Dir.mktmpdir {|tmp|
+ Dir.chdir(tmp) {
+ File.open("test.rb", "w") do |f|
+ f.puts <<-EOS
+ def coverage_test_method
+ :ok
+ end
+ EOS
+ end
+
+ Coverage.start
+ require tmp + '/test.rb'
+ Coverage.result
+ Coverage.start
+ coverage_test_method
+ assert_equal 1, Coverage.result.size
+ }
+ }
+ ensure
+ $".replace loaded_features
+ end
end