Topic: rcov always 100%
I've been using rcov on rails projects for a while, and it does work great. I'm trying to use it on a non-rails ruby project, but it always seems to report the code is 100% tested. I made a small test lib:
class Call
attr_accessor :cpn, :cdn
def initialize(hsh={})
@cpn = hsh[:cpn]
@cdn = hsh[:cdn]
end
# simple untested instance method
def to_s() "#{@cpn} - #{@cdn}" end
# even simpler method not even using instance vars, completely untested
def boo() 42 end
endand a test:
require 'test/unit'
require 'call.rb'
class CallTest < Test::Unit::TestCase
def test_new
assert call = Call.new({:cpn => 1234567890, :cdn => 9876543210})
end
endrcov passes:
$ rcov call_test.rb
Loaded suite /usr/local/bin/rcov
Started
.
Finished in 0.000268 seconds.
1 tests, 1 assertions, 0 failures, 0 errorsbut web page says lib is 100% covered. Am I building my test/lib weird? rcov is relevance-rcov (0.9.2.1), ruby is ruby 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux]
Last edited by datajedi (2010-02-09 13:57:37)