Testing private method in Ruby (rspec) [duplicate]

You can call a private method in ruby using the send method. Something like this:

@my_object = MyObject.new
@my_object.send(:do_things_with_message, some_message)

In a test that would look something like:

it "should do a thing" do
  my_object = MyObject.new
  my_object.send(:do_things_with_message, some_message)
  my_object.thing.should == true
end

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)