Forum: Ruby on Rails rcov not detecting existing and valid test cases

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
242dfb8324501cb3b020625639044377?d=identicon&s=25 Vahagn Hayrapetyan (vahagn)
on 2009-01-06 18:01
Hello,-

got a question regarding strange behavior by rcov.

I have a gyms_controller.rb with the usual group of CRUD methods. Each
one of them is being tested in the gyms_controller_test.rb:

$ ruby test/functional/gyms_controller_test.rb
Loaded suite test/functional/gyms_controller_test
Started
.........
Finished in 5.985611 seconds.

9 tests, 20 assertions, 0 failures, 0 errors

So far, so good.

Then, I've installed rcov and the majority of the code that is being
tested is marked as not covered by the test. In particular, the fairly
trivial test for the index action:

  5   # GET /gyms
  6   # GET /gyms.xml
  7   def index
  8     @gyms = Gym.find(:all)
  9     respond_to do |format|
 10       format.html # index.html.erb
 11       format.xml  { render :xml => @gyms }
 12     end
 13   end

And the test:

 def test_should_get_index
    get :index
    assert_response :success
    assert_not_nil assigns(:gyms)
  end

This is a test that is being executed and does not fail. How come it's
not detected by rcov??

Thanks!

/ Vahagn
This topic is locked and can not be replied to.