From: Christoph Olszowka Date: 2011-09-17T23:58:29+09:00 Subject: [ruby-core:39611] [Ruby 1.9 - Bug #5333][Open] Coverage library giving wrong results Issue #5333 has been reported by Christoph Olszowka. ---------------------------------------- Bug #5333: Coverage library giving wrong results http://redmine.ruby-lang.org/issues/5333 Author: Christoph Olszowka Status: Open Priority: Normal Assignee: Yusuke Endoh Category: lib Target version: 1.9.2 ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0] I'm the author of the simplecov gem, a wrapper on top of the Coverage library. You can find it on Github at https://github.com/colszowka/simplecov I keep getting reports from users that code they have cleary tested is not reported as covered (you can find it a discussion at https://github.com/colszowka/simplecov/issues/60). This was very hard to trace back since no one was able to give me code samples so far. A couple of days ago, a user finally came up with a sample rails application where this problem was visible in conjunction with FactoryGirl. I tried this out using the Coverage library directly, and the result was the same: Creating the record directly reported the file as covered, doing the same with FactoryGirl reported a coverage of 0 for certain lines - even though they were executed. I forked the application and added some instructions to the readme. You can find it at https://github.com/colszowka/coverage-bug I verified this on the latest 1.9.2 release as well as 1.9.3-preview1: ruby 1.9.3dev (2011-07-31 revision 32789) [x86_64-darwin11.0.0] ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0] I'm not sure why this happens in conjunction with FactoryGirl, but the code inside the if-statement is being executed in that case as well as I verified by adding a raise inside there and getting a correctly failing rspec suite. Please let me know if you need any further information on this -- http://redmine.ruby-lang.org