# Testing partials

**URL:** <https://www.ruby-forum.com/t/testing-partials/186842>\
**Category:** Rails\
**Created:** [April 13, 2010, 10:06am UTC](https://www.ruby-forum.com/t/testing-partials/186842 "2010-04-13T10:06:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [April 13, 2010, 10:06am UTC](https://www.ruby-forum.com/t/testing-partials/186842/1 "2010-04-13T10:06:03Z")

</div>

Guys,

How can we test partials and layouts… ? Googled but find nothing  
useful…

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [April 13, 2010, 4:30pm UTC](https://www.ruby-forum.com/t/testing-partials/186842/2 "2010-04-13T16:30:30Z")

</div>

On Tue, Apr 13, 2010 at 5:06 AM, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Guys,
> 
> ## How can we test partials and layouts… ? Googled but find nothing useful…

In the same way you test your views. You can use Selenium if you like.  
I don’t like the use of Selenium for this, I prefer to test the views  
contain the text that should be there and delegate the full testing of  
the view to a human tester. (Probably myself, but can be other people  
if you have a test team)

Hope it helps.

–  
Leonardo M…  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [April 13, 2010, 4:33pm UTC](https://www.ruby-forum.com/t/testing-partials/186842/3 "2010-04-13T16:33:12Z")

</div>

Hi Leonardo,

I am not using any tool for tesing. Neither i want to…

Leonardo M. wrote:

> > –  
> > In the same way you test your views. You can use Selenium if you like.  
> > I don’t like the use of Selenium for this, I prefer to test the views  
> > contain the text that should be there and delegate the full testing of  
> > the view to a human tester. (Probably myself, but can be other people  
> > if you have a test team)
> 
> Hope it helps.
> 
> –  
> Leonardo M…  
> There’s no place like ~

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [April 13, 2010, 5:03pm UTC](https://www.ruby-forum.com/t/testing-partials/186842/4 "2010-04-13T17:03:53Z")

</div>

On Tue, Apr 13, 2010 at 11:33 AM, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi Leonardo,
> 
> I am not using any tool for tesing. Neither i want to…  
> So, you’re asking how to test your views, and you don’t want to use  
> any tool for testing?  
> I assume you have your reasons for not doing any testing, but if you  
> don’t want to use any tool, you’ll have to test them by hand.

–  
Leonardo M…  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [April 13, 2010, 9:59pm UTC](https://www.ruby-forum.com/t/testing-partials/186842/5 "2010-04-13T21:59:37Z")

</div>

If you are using functional tests, then just use assert\_select to verify  
that the HTML that the partial generates is somewhere in the response.  
For  
example, if you have a partial that prints out “

hello
”, test  
a  
controller that has a view that calls that partial, and then do

assert\_select “div”, “hello”

then you’ll know the partial worked.
