[rspec-users] How do you mock a local variable ?

David Chelimsky dchelimsky at gmail.com
Sun Mar 1 18:18:22 EST 2009


Sorry all - this was sitting waiting for moderation, but it's already
been addressed.

Cheers,
David

On Thu, Feb 26, 2009 at 2:43 PM, MathLef <mlefrancois19 at gmail.com> wrote:
> Hi,
>
> 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 :
>
> private
> 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
> end
>
>  - hash_params is a hash table of some parameters received by a
> controller
>  - 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 !
> Mathieu
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list