Forum: RSpec How do you mock a local variable ?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
MathLef (Guest)
on 2009-03-02 01:03
(Received via mailing list)

I need some help to spec' a function I am developping. Note that the
function is still not complete, cause I am trying to spec' it while
working on it, as it should be ! Basically, this is what my function
should look like :

def obtain_criterias(hash_params)
  crits = {}
  hash_params.each {
   |key, val|
    crits[key.to_sym] = StringUtils.sanitize(val).upcase if not (key
== "controller" || key == "action")
  return crits

 - hash_params is a hash table of some parameters received by a
 - StringUtils.sanitize removes all kind of accents from the string
passed in parameters
 - it is encapsulated in a controller

The problem is with the local variable "crits" on which I can not seem
to have any kind of control in my rspec. Now, I am wandering, is this
(still) a good way to code from a spec point of view ?! Can you give
me ideas on ways to spec this ?

Many thanks in advance !
David C. (Guest)
on 2009-03-02 01:20
(Received via mailing list)
Sorry all - this was sitting waiting for moderation, but it's already
been addressed.

This topic is locked and can not be replied to.