Just after some clarification on how simplecov determines if a line has been exercised by a test.
I have the following method:
def over?
end_at < Time.zone.now
end
in which end_at is an ActiveRecord attribute on the object.
Which is exercised in the following spec:
describe CalendarEntry do
it 'can determine that an event has ended' do
@entry.end_at = 1.day.ago
@entry.over?.should be_true
end
end
After running the spec with coverage, it shows the following result:
I've run the test in debug mode with a break point on this line and confirmed that the spec is indeed hitting it.
This isn't isolated to just this line in this method, every line that includes the use of an ActiveRecord associated getter is shown as not covered. Could be coincidence, but seems a bit odd.
Environment: ruby 1.9.3-p327 (mri), rails 3.2.8, simplecov 0.7.1, rspec 2.10.0.
Any ideas on why simplecov thinks it's not covered?
OK so I add the same kind of problem with JRuby running on Windows. The answer was actually prompted to me, Simplecov can miss some lines if not runned in debug mode.
(j)ruby --debug -S rspec spec
With the --debug option it did worked and I was back to 100% coverage as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With