Forum: Ruby on Rails rcov not detecting request.xhr? test

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.
Greg D. (Guest)
on 2009-02-20 00:23
(Received via mailing list)
I have a method

def index
  if request.xhr?
    @users = User.find( :all )
  end
end

And then I have a test for it:

def test_index
  user = users( :foo )
  xhr :post, :index, {}, { :user_id => user.user_id }
  assert_response :success
  assert_template 'users/index'
end

The test works fine.  If I put a puts in there it fires, so I know the
test is hitting the block in question.

So then when I run rcov, it produces a report that says the code block
has not yet been covered with a test.

I also tried xhr :get in my test but got the same result.

Anyone know anything about this?  Is there a workaround, or another way?


Thanks,


--
Greg D.
http://destiney.com/
This topic is locked and can not be replied to.