Hi, I don't know if I'm doing something wrong, but I have a model with two methods, and even the test passing, the coverage file isn't being marked as covered. The code:
class List < ActiveRecord::Base
status == 'closed'
status == 'open'
class ListTest < ActiveSupport::TestCase
test "should respond true to the closed? method" do
list = create(status: 'closed')
assert list.closed?, "a closed list is not responding true to closed? method"
test "should respond true to the open? method" do
list = create(status: 'open')
assert list.open?, "a opened list is not responding true to open? method"
description: 'Test list',
the return of method open? isn't being covered. Why?
Hi, please check out #60, I think your issue is the same. There's a solution at the bottom.
Ok, I'll reply on this Issue because I think the problem isn't related to #60, since I tried the following and my problem still remains:
1. Upgrade my rails version to 3.2
2. Force config.cache_classes = true.
config.cache_classes = true
Now, I tried run only my units tests rake test:units, and those lines are being marked covered. After, running all tests again rake test, then I got those lines marked uncovered again. Are the functionals tests overriding units tests in some methods or something like it? Am I doing something wrong?
Actually, you're right - something in the test suite detection seems to have went down the drain on the road to Rails 3.2 and I was able to reproduce this bug. Reopened, sorry for making too early conclusions
What you can do to temporarily fix this (note that this only has to be done in ONE file per test suite as it will apply to the whole SimpleCov config for that process):
SimpleCov.command_name 'Unit Tests'
SimpleCov.command_name 'Functional Tests'
SimpleCov.command_name 'Integration Tests'
This will make SimpleCov ditch it's own CommandGuesser class and use the suite names you provided. Keeping this open as it definetely needs to get fixed though :)
Just to let you know, your temporarily fix worked here.
Thanks for the "temp" fix. It worked for me to :) - ruby 1.9.3-p0, rails 3.2.1
I'm having the same issue here. Temp fix worked, thanks.
So, the offender here is lib/rake/rake_test_loader.rb in recent Rake releases as it's tampering with ARGV and removing the loaded test suite information for simplecov to figure out what Rails suite is running. I'm on it, a fix will be included in the next release.
Prevent libraries that tamper with ARGV (I'm looking at you, rake)
from disabling SimpleCov's ability to guess test suite / framework names
based upon the command line call that invoked the tests.
Fixes #110 and probably also #45
Cleaned up and refactored the command guessing along the way.
v0.6.0 is out and should resolve this. At least it did in my local tests on a fresh 3.2.1 Rails app :)