Dear group,

I'm trying to implement a sign in and out machinery and I'm currently have
the logic in a helper
module called SessionsHelper but according to good OO and separation of
concerns I want to
separate the SignIn and SignOut logic to its own module and only keep the
cookies related stuff in
the SessionsHelper module (cause those are better there).

By this I'll have perfectly fast and isolated tests for SignIn and Out
module and also I'm not mixing
these all together. and finally I'll include the SignInOut module in the
SessionsHelper like the following:

module SessionsHelper

include SignInOut

def create_cookie(user_id, user_salt)
//creation of cookie
end

def remember_token
//get token from cookie
end

def delete_cookie
//deletion of cookie
end

end

But I want to be able to stub these methods (create_cookie etc.) in the
SignInOut spec cause I want
to express some expectations in those specs for live documentation sake and
other stuff too. How can
I stub module's methods in this style? I know I can stub static methods of
modules like this:
SessionsHelper.stub(:static_method).and_return("foobar")

but how can I stub non-static methods of modules like these 3 methods here?
I really appreciate your
help on this.

Thanks in advance for your help.
Best Regards

--
Sam Serpoosh
Software Developer: http://masihjesus.wordpress.com
Twitter @masihjesus

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJul 16, '12 at 11:42a
activeJul 16, '12 at 11:42a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Sam Serpoosh: 1 post

People

Translate

site design / logo © 2023 Grokbase