# How to assert a simple link (testing)

**URL:** <https://www.ruby-forum.com/t/how-to-assert-a-simple-link-testing/143002>\
**Category:** Rails\
**Created:** [July 14, 2008, 12:09pm UTC](https://www.ruby-forum.com/t/how-to-assert-a-simple-link-testing/143002 "2008-07-14T12:09:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 14, 2008, 12:09pm UTC](https://www.ruby-forum.com/t/how-to-assert-a-simple-link-testing/143002/1 "2008-07-14T12:09:55Z")

</div>

\<%= link\_to ‘my\_profile’,:controller =\> ‘users’, :action =\> ‘show’, :id  
=\> current\_user.id %\>

[my\_profile](http://localhost:3000/users/show/2)

What is the easy and simple way to assert this link in testing.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 14, 2008, 2:24pm UTC](https://www.ruby-forum.com/t/how-to-assert-a-simple-link-testing/143002/2 "2008-07-14T14:24:09Z")

</div>

On Jul 14, 11:09 am, Raj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> \<%= link\_to ‘my\_profile’,:controller =\> ‘users’, :action =\> ‘show’, :id  
> =\> current\_user.id %\>
> 
> [my\_profile](http://localhost:3000/users/show/2)
> 
> What is the easy and simple way to assert this link in testing.

What are you trying to assert? That the correct link was generated ?  
That the link corresponds to a page that exists? Something else?

Fred

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 14, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/how-to-assert-a-simple-link-testing/143002/3 "2008-07-14T14:46:20Z")

</div>

That the page has a link which has href content as  
[http://localhost:3000/users/show/2](http://localhost:3000/users/show/2) and the correspoding text is  
‘my\_profile’ in the html document.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [July 14, 2008, 3:08pm UTC](https://www.ruby-forum.com/t/how-to-assert-a-simple-link-testing/143002/4 "2008-07-14T15:08:41Z")

</div>

On Jul 14, 1:46 pm, Raj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> That the page has a link which has href content ashttp://localhost:3000/users/show/2and the correspoding text is  
> ‘my\_profile’ in the html document.

assert\_select/assert\_tag allow you to do that (although I’d consider  
this to be a bit over the top)

Fred
