# Testing find\_by\_sql

**URL:** <https://www.ruby-forum.com/t/testing-find-by-sql/122298>\
**Category:** Rails\
**Created:** [December 6, 2007, 11:51am UTC](https://www.ruby-forum.com/t/testing-find-by-sql/122298 "2007-12-06T11:51:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kabish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a88e57/32.png) [@kabish](https://www.ruby-forum.com/u/kabish)\
**Post date:** [December 6, 2007, 11:51am UTC](https://www.ruby-forum.com/t/testing-find-by-sql/122298/1 "2007-12-06T11:51:16Z")

</div>

Hi all,

I have a controller method that, given some parameters, constructs a big  
sql query and passes it to find\_by\_sql (with pagination).

The point is that I can’t wonder how to write a functional test for this  
method. Has anyone passed already through this?

---

<div class="post-metadata">

**Author:** ![kabish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a88e57/32.png) [@kabish](https://www.ruby-forum.com/u/kabish)\
**Post date:** [December 6, 2007, 12:26pm UTC](https://www.ruby-forum.com/t/testing-find-by-sql/122298/2 "2007-12-06T12:26:34Z")

</div>

> The point is that I can’t wonder how to write a functional test for this  
> method. Has anyone passed already through this?

create lots of fixtures that contain all possible cases  
make get/post calls with all possible parameters (and combinations of  
parameters)  
check if your find\_by\_sql results are what you expect

just the same as in a ‘normal’ action with find or find\_all\_by\_…
