tag:blogger.com,1999:blog-12467669.post7527590632703896065..comments2023-04-29T07:23:25.825-04:00Comments on Jay Fields' Thoughts: Ruby: === operatorJayhttp://www.blogger.com/profile/14491442812573747680noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-12467669.post-31090310438629983562007-03-27T10:28:00.000-04:002007-03-27T10:28:00.000-04:00Good stuff guys. Sorry for delayed response - I've...Good stuff guys. Sorry for delayed response - I've been on holiday. I'll look at getting something committed asap.floehopperhttps://www.blogger.com/profile/09918245606161265832noreply@blogger.comtag:blogger.com,1999:blog-12467669.post-20988583585688764102007-03-24T14:55:00.000-04:002007-03-24T14:55:00.000-04:00OK - I posted a second patch with an_instance_of. ...OK - I posted a second patch with an_instance_of. We'll have to see what James has to say. He may not like the idea to begin with, although the implementation doesn't really change anything internal to mocha, so it can ship separately. <BR/><BR/>Thanks for the feedback Jay.<BR/><BR/>Cheers,<BR/>DavidAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-52304177399061361022007-03-24T14:43:00.000-04:002007-03-24T14:43:00.000-04:00I can speculate, but I think I'd need to get tired...I can speculate, but I think I'd need to get tired of typing before I decided something was too verbose. As far as adding the and, I don't see it as necessary since the ',' in the with arguments already currently plays the 'and' role.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-89675759893912482252007-03-24T14:29:00.000-04:002007-03-24T14:29:00.000-04:00Hi Jay - I agree with you in this case in isolatio...Hi Jay - I agree with you in this case in isolation. It does concern me that things could start getting quite verbose as more matchers are added:<BR/><BR/>obj.expects(:msg).with(an_instance_of(String), a_value_greater_than(5))<BR/><BR/>In this case, I start wanting to see:<BR/><BR/>obj.expects(:msg).with(an_instance_of(String)).and( a_value_greater_than(5))<BR/><BR/>But that starts to really complicate things. There's a point of diminishing returns when it comes to increasing readability. I'm not sure where that point lies here.<BR/><BR/>WDYT?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-84990393756808359672007-03-24T14:17:00.000-04:002007-03-24T14:17:00.000-04:00David,I like the concept in general, but I think i...David,<BR/><BR/>I like the concept in general, but I think is_a reads poorly. I would prefer an (admittedly more verbose) an_instance_of method. I think the mock definition would read better as<BR/><BR/>obj.expects(:foo).with(an_instance_of(Fixnum), an_instance_of(String)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-24573478754410417092007-03-24T13:39:00.000-04:002007-03-24T13:39:00.000-04:00We use argument matchers in rspec. To be honest, I...We use argument matchers in rspec. To be honest, I don't like our implementation (mine ;) ), but I just submitted a <A HREF="http://rubyforge.org/tracker/index.php?func=detail&aid=9521&group_id=1917&atid=7479" REL="nofollow">patch to mocha</A> that would allow you to do this:<BR/><BR/>obj.expects(:message).with(is_a(Fixnum))<BR/><BR/>Whether or not James accepts the patch, I'd love your feedback on it.<BR/><BR/>Cheers,<BR/>DavidAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-57015975162482345972007-03-23T16:18:00.000-04:002007-03-23T16:18:00.000-04:00David,I intentionally added that behavior since:Fi...David,<BR/><BR/>I intentionally added that behavior since:<BR/><BR/>Fixnum === Fixnum #=> false<BR/><BR/>The ambiguity does bother me, but not being able to test for the value Fixnum seemed like a worse option. I think the real long term solution will be more complicated.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-75990758366135298792007-03-23T16:10:00.000-04:002007-03-23T16:10:00.000-04:00If I read the tests correctly, expecting Fixnum wi...If I read the tests correctly, expecting Fixnum will match either Fixnum (the actual Class object) or an instance of Fixnum. Am I correct? If so, does this bug you at all?Anonymousnoreply@blogger.com