# Problem with gettext and functional tests

**URL:** <https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354>\
**Category:** Rails\
**Created:** [July 6, 2006, 3:45pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354 "2006-07-06T15:45:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Markus\_Piff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@Markus\_Piff](https://www.ruby-forum.com/u/Markus_Piff)\
**Post date:** [July 6, 2006, 3:45pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354/1 "2006-07-06T15:45:52Z")

</div>

Hi,

I am using gettext to let my web application know several languages. All  
works fine, but since I integrated it, my functional tests don’t work  
any  
more.  
I keep getting the error message:  
NoMethodError: undefined method `cgi’ for  
#ActionController::TestRequest:0xb77f7f88.

All right, TestRequest doesn’t have a cgi method. Therefore I just  
included  
this into test\_helper.rb:  
ActionController::TestRequest.send(:include, CGI::QueryExtension).

Now the error message changes to:  
NameError: undefined local variable or method `env\_table’ for  
#ActionController::TestRequest:0xb7785848.

Great, but then there isn’t a module left (the cgi class is the only  
construct, which implements it), which I could use to include env\_table;  
and  
I really don’t want to start cgi hacking…

How should I solve this problem?  
Any help is greatly appreciated.

Markus

P.S.: Is this normal behaviour that the TestRequest class isn’t cgi  
capable?

---

<div class="post-metadata">

**Author:** ![Markus\_Piff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@Markus\_Piff](https://www.ruby-forum.com/u/Markus_Piff)\
**Post date:** [July 6, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354/2 "2006-07-06T18:15:46Z")

</div>

Hi,

What version of Ruby-GetText you use?  
1.6.0 ?

I’ve fixed similer problem once. But if you  
use 1.6.0, there has been another problem yet.

And also tell me your environment detail.

# show me the result of “ruby script/about”.

On Thu, 6 Jul 2006 15:44:10 +0200

---

<div class="post-metadata">

**Author:** ![Markus\_Piff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@Markus\_Piff](https://www.ruby-forum.com/u/Markus_Piff)\
**Post date:** [July 6, 2006, 9:57pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354/3 "2006-07-06T21:57:59Z")

</div>

Hi,

first of all thank you for your response.  
@Chuck: Since I am using rails 1.0, integration tests will all go fine,  
because there are none in rails 1.0 ;-).

@Masao: I was using ruby-gettext 1.0, but after your email I tried all  
kinds  
of versions. All result to the same error. What’s a good and stable  
version  
of gettext anyway?

Here is the output of ruby script/about:  
About your application’s environment  
Ruby version 1.8.4 (i486-linux)  
RubyGems version 0.8.11  
Rails version 1.0.0  
Active Record version 1.13.2  
Action Pack version 1.11.2  
Action Web Service version 1.0.0  
Action Mailer version 1.1.5  
Active Support version 1.2.5  
Application root /home/markus/workspace/jobs  
Environment development  
Database adapter mysql

Any ideas left?  
I really appreciate your help, I am already getting somewhat desperate  
🙂 .

Markus

---

<div class="post-metadata">

**Author:** ![Markus\_Piff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@Markus\_Piff](https://www.ruby-forum.com/u/Markus_Piff)\
**Post date:** [July 13, 2006, 6:00pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354/4 "2006-07-13T18:00:03Z")

</div>

Hi,  
just to complete this.  
I finally found a solution, which even seems a bit silly; but hey it  
works  
:-).

I just had to include the following to test\_helper.rb:

class ActionController::TestRequest; def cgi() end; end

Thanks again for helping,  
Markus

---

<div class="post-metadata">

**Author:** ![Markus\_Piff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@Markus\_Piff](https://www.ruby-forum.com/u/Markus_Piff)\
**Post date:** [July 6, 2006, 6:53pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354/5 "2006-07-06T18:53:33Z")

</div>

On 7/6/06, Masao M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > NoMethodError: undefined method `cgi’ for  
> > Great, but then there isn’t a module left (the cgi class is the only  
> > construct, which implements it), which I could use to include env\_table; and  
> > I really don’t want to start cgi hacking…
> > 
> > How should I solve this problem?  
> > Any help is greatly appreciated.
> > 
> > Markus
> > 
> > P.S.: Is this normal behaviour that the TestRequest class isn’t cgi capable?

Do you have the same problems with Integration tests? Functional and  
Integration tests share mostly the same structure so it would be easy  
to test but I find that there are things in the functional tests that  
are missing that are present in the Integration tests.

Cheers,  
Chuck V.

---

<div class="post-metadata">

**Author:** ![Markus\_Piff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@Markus\_Piff](https://www.ruby-forum.com/u/Markus_Piff)\
**Post date:** [July 13, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354/6 "2006-07-13T18:26:46Z")

</div>

Hi,

On Thu, 13 Jul 2006 17:52:28 +0200  
“Markus Piff” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,  
> just to complete this.  
> I finally found a solution, which even seems a bit silly; but hey it works  
> :-).
> 
> I just had to include the following to test\_helper.rb:
> 
> class ActionController::TestRequest; def cgi() end; end

Hmm. Strange.  
There is the same code in gettext/rails.rb (Since 1.5.0) .  
Did you “require ‘gettext/rails’” anywhere ?

---

<div class="post-metadata">

**Author:** ![Markus\_Piff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ba0ec/32.png) [@Markus\_Piff](https://www.ruby-forum.com/u/Markus_Piff)\
**Post date:** [July 15, 2006, 1:43pm UTC](https://www.ruby-forum.com/t/problem-with-gettext-and-functional-tests/97354/7 "2006-07-15T13:43:36Z")

</div>

Hi!

In rgettext 1.0 there is no such code.  
And as I already told you before, I tried all kinds of rgettext versions  
(all installed with gem) but all resulted to the same error.  
Of course I had a require “gettext/rails” included; otherwise other  
errors  
would have shown up.

Anyways the thing works now 🙂  
Markus
