mercredi 2 septembre 2015

Testing a method chain with arguments and code block

In my project I have a chained method I want to test in rspec:

a = obj1
     .method1(arg1, arg2)
     .method2(arg3, arg4)
     .method3(arg5, arg6) { |a, b| # some block code here ... }

     # => some result, doesn't matter

Here's how I'm trying to test it:

before { allow(obj1).to receive_message_chain(:method1, method2, method3)

As you can see, all 3 methods are called with the arguments which is wrong. How can I add the arguments to them and the code block to method3?

Aucun commentaire:

Enregistrer un commentaire