[rspec-users] Testing initialize methods and chained methods

Justin Ko jko170 at gmail.com
Tue Oct 19 09:09:29 EDT 2010

On Oct 19, 3:56 am, Oscar Del Ben <thehcdrea... at gmail.com> wrote:
> I'm having some troubles understanding how to test a couple of things.
> Usually, if I'm having trouble testing something, it means that my design
> could probably be improved or changed, but in these cases I think I'm doing
> the right thing.
> Here's the first scenario:
> class Foo
>   def initialize
>     do_something
>   end
> end
> Here I have no idea how to test that the do_something method is called.
> Another issue I have is with the following code:
> my_method.another_chained_method.something_else
> Here I'm having trouble understanding how to test that my_method receives
> another_chained_method and so on.
> Any help would be very appreciated. Thanks!
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

How does the initialize method usually get called? By call ".new" on
the class.

Here is some docs on your new friend "stub_chain"

I'm in a hurry, sorry I can't help more than that.

More information about the rspec-users mailing list