# Case insensitivity in assert

**URL:** <https://www.ruby-forum.com/t/case-insensitivity-in-assert/134129>\
**Category:** Rails\
**Created:** [April 8, 2008, 5:01am UTC](https://www.ruby-forum.com/t/case-insensitivity-in-assert/134129 "2008-04-08T05:01:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![complete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@complete](https://www.ruby-forum.com/u/complete)\
**Post date:** [April 8, 2008, 5:01am UTC](https://www.ruby-forum.com/t/case-insensitivity-in-assert/134129/1 "2008-04-08T05:01:48Z")

</div>

I’m only a few days old in this whiz-bang rails world, so bear with me.

I’m in the middle of running functional tests, I’ve got some assert  
statements that check for the presence of a various tags on the page…  
One of the tags being checked is a form, and assert\_tag checks that its  
:method =\> “POST”. Unfortunately, the autogenerated form shows the value  
“post”, and apparently that’s just too much different (the assert  
fails).

Is there a way to call a case-insensitive assert? Here’s the code in  
question:

assert\_tag “form”,  
:attributes =\> { :action =\> “/user/register”,  
:method =\> “POST” }

I realize I can just change the assert to check for “post” and  
everything will be peachy, but this seems like something that could  
cause me problems again down the road if I don’t figure it out now.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![complete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@complete](https://www.ruby-forum.com/u/complete)\
**Post date:** [April 8, 2008, 9:29am UTC](https://www.ruby-forum.com/t/case-insensitivity-in-assert/134129/2 "2008-04-08T09:29:53Z")

</div>

On Apr 8, 4:01 am, William T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> cause me problems again down the road if I don’t figure it out now.

You can give assert\_tag a regular expression instead of just a string  
(and assert\_select is often used instead of assert\_tag these days)

Fred

---

<div class="post-metadata">

**Author:** ![complete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@complete](https://www.ruby-forum.com/u/complete)\
**Post date:** [April 8, 2008, 10:48am UTC](https://www.ruby-forum.com/t/case-insensitivity-in-assert/134129/3 "2008-04-08T10:48:48Z")

</div>

Frederick C. wrote:

> On Apr 8, 4:01ï¿½am, William T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > cause me problems again down the road if I don’t figure it out now.
> 
> You can give assert\_tag a regular expression instead of just a string  
> (and assert\_select is often used instead of assert\_tag these days)
> 
> Fred

Doh. Thanks, and for the assert tip.

Cheers  
cb

---

<div class="post-metadata">

**Author:** ![complete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@complete](https://www.ruby-forum.com/u/complete)\
**Post date:** [April 8, 2008, 9:44pm UTC](https://www.ruby-forum.com/t/case-insensitivity-in-assert/134129/4 "2008-04-08T21:44:10Z")

</div>

Phlip wrote:

> William T. wrote:
> 
> > > You can give assert\_tag a regular expression instead of just a string  
> > > (and assert\_select is often used instead of assert\_tag these days)
> 
> > Doh. Thanks, and for the assert tip.
> 
> Can you improve the code so its case is consistent? That would seem to  
> fix the  
> root problem here…
> 
> –  
> Phlip

I’m not really sure – the code is generated with form\_for, and while I  
would imagine that function will consistently generate a lower-case  
“post”, I’m not comfortable trusting the rest of the language (or  
myself) to stick with that convention.

The regular expression did it.

---

<div class="post-metadata">

**Author:** ![complete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@complete](https://www.ruby-forum.com/u/complete)\
**Post date:** [April 8, 2008, 12:06pm UTC](https://www.ruby-forum.com/t/case-insensitivity-in-assert/134129/5 "2008-04-08T12:06:27Z")

</div>

William T. wrote:

> > You can give assert\_tag a regular expression instead of just a string  
> > (and assert\_select is often used instead of assert\_tag these days)

> Doh. Thanks, and for the assert tip.

Can you improve the code so its case is consistent? That would seem to  
fix the  
root problem here…

–  
Phlip
