[rspec-users] Spec-ing private method

Andrey S. lists at ruby-forum.com
Thu May 16 03:22:28 UTC 2013


Yes, I know, that testing private methods it's not a good idea (and I
read this thread - http://www.ruby-forum.com/topic/197346 - and some
others)

But how can I test the following code?
I use xmpp4r. In my public method #listen I start receive jabber
messages like so:

def listen
  @client.add_message_callback do |m|
    do_things_with_message(m)
  end
end

private
def do_things_with_message(m)
  #
end

#add_message_callback - runs block, when message come

So, testing #listen method it's difficult and it more testing xmpp4r
than my #do_things_with_message

How to do all right and test #do_things_with_message? :)
(http://www.ruby-forum.com/topic/197346#859664)

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list