8

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:

coverage report

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?

4

1 に答える 1

1

わかりましたので、Windows で実行されている JRuby に同じ種類の問題を追加します。答えは実際に私に尋ねられました.Simplecovは、デバッグモードで実行されていない場合、いくつかの行を見逃す可能性があります.

(j)ruby --debug -S rspec spec

--debug オプションを使用すると機能し、予想どおり 100% のカバレッジに戻りました。

于 2013-01-28T12:14:51.263 に答える