# Rcov not detecting request.xhr? test

**URL:** <https://www.ruby-forum.com/t/rcov-not-detecting-request-xhr-test/160815>\
**Category:** Rails\
**Created:** [February 19, 2009, 11:23pm UTC](https://www.ruby-forum.com/t/rcov-not-detecting-request-xhr-test/160815 "2009-02-19T23:23:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 19, 2009, 11:23pm UTC](https://www.ruby-forum.com/t/rcov-not-detecting-request-xhr-test/160815/1 "2009-02-19T23:23:49Z")

</div>

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/](http://destiney.com/)
