# Undefined local variable or method \`request' â€”in test

**URL:** <https://www.ruby-forum.com/t/undefined-local-variable-or-method-request-a-in-test/186057>\
**Category:** Rails\
**Created:** [March 30, 2010, 11:05pm UTC](https://www.ruby-forum.com/t/undefined-local-variable-or-method-request-a-in-test/186057 "2010-03-30T23:05:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 30, 2010, 11:05pm UTC](https://www.ruby-forum.com/t/undefined-local-variable-or-method-request-a-in-test/186057/1 "2010-03-30T23:05:00Z")

</div>

I am working on a small gem patch… The code in question is in a  
module within /lib. I am calling request.env[‘HTTP\_REFERER’] and  
getting the desired results as implementation in the dev env.

However, when I run my RSpec spec, I get:  
undefined local variable or method `request’ for  
#Spec::Example::ExampleGroup::Subclass\_1::Subclass\_1:0x10057d518

I am assuming that somehow “request” is not getting initialized when  
in the test env. etc… Coming from the test/unit and Shoulda world, I  
know very little about RSpec, perhaps this is playing a role in my  
problem as well.

Any insight here?

Thanks!  
Elliott G

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 31, 2010, 7:37pm UTC](https://www.ruby-forum.com/t/undefined-local-variable-or-method-request-a-in-test/186057/2 "2010-03-31T19:37:05Z")

</div>

Any thoughts on this one guys?

Thanks
