[rspec-users] Private method in custom module

Phillip Koebbe phillipkoebbe at gmail.com
Thu Dec 31 15:05:21 EST 2009


Hi David,

First, thanks for the suggestion. I like that better.

Second, my motivation for doing this was born out of not being able to
do something I wanted to do in Remarkable. However, as I was trying to
explain what it was I wanted to do, I just discovered how to do it in
Remarkable. So, the immediate need for knowing how to call a private
method is no longer valid, but I would like to go ahead and explain
what I was trying to do to see if it is actually possible. I still
have custom macros that I might need to refactor at some point.

Here is the relevant code example:

http://gist.github.com/266873

[By the way, I didn't intend for the gist to be formatted quite like
that. I am fond of 4 character tabs, but I realize that most people in
the ruby community use 2 spaces, so I copied the code to a new
textmate window, reformatted it, then copied and pasted into the gist.
But it still come out like that, so I don't know what I'm supposed to
do.]

I was attempting to create my own should_set_session so I could use
values from instance variables. I didn't see how to do that in
Remarkable until just a few minutes ago. It can be accomplished by
using :to => proc { @user.id }.

I was experimenting with where to call get_value_from_options from.
When I try inside the "it", I get the NoMethodError. When I call it
from outside of the it, get_value_from_options gets called, but then I
don't get the instance variable like I expect. I believe I understand
why that is, though. The instance var is created in the before, which
is more or less an it, so it has the same scope. So when called from
outside of the it, there is no instance var @user.

So my question now is simply: Can I even do what I want to do?

Thanks,
Phillip


More information about the rspec-users mailing list