Stub and setting expectation on method which takes ruby shorthand block as parameter
31 views
Skip to first unread message
siva
unread,
Feb 25, 2014, 11:47:55 PM2/25/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rs...@googlegroups.com
Hi Guys
I have query as `Enquiry.all.group_by(&:assigned_to)`. How can I stub and set expectation on `group_by` method?
Thanks in advance.
Xavier Shay
unread,
Feb 26, 2014, 1:16:59 AM2/26/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rs...@googlegroups.com
On 25/02/14 8:47 PM, siva wrote:
>
> Hi Guys
>
> I have query as `Enquiry.all.group_by(&:assigned_to)`. How can I
> stub and set expectation on `group_by` method?
specific answer: use stub_chain
meta-answer: don't do that, refactor your code. 2 reasons: you're
mocking an object you don't control, and you're violating law of demeter.