Closed catriuspham closed 7 years ago
Can we call it be_similar_to
? to similar to
sounds awkward.
@seri-ea You can use to.be.similar_to
. Nice catch, though.
I see @catriuspham Never mind. I think we can leave it this way. Maybe we should use the better style (be.similar_to) in documentation though.
Hm. I'm really sorry but I think we should not merge this PR.
s1 = standardize(...)
s2 = standardize(...)
expect(s1).to.be.eq(s2)
expect(something).to.be.similar(the_other)
I think it should be
expect(similarity(something, the_other)).to.be.less_than(0.8)
for example. Because in test, we want to check something precisely, exactly equal, rather than similar.
Then, please let me know more about your idea about these points.
@hieueastagile On the first point: Actually I was about to make the exact same comment. This matcher doesn't seem general enough. I mean, what is the definition on string similarity after all? No one can agree on a standard.
But then you said "String similarity is great, we can implement it." on https://github.com/EastAgile/robber.py/issues/37 so I skipped it. You probably thought of something else on that issue page. (Edit-distance as your last point).
So anyway, agree that this PR as-is should not be merged.
What I refer to similarity
is my last idea at that time.
Actually, I got the idea straight from Sure (http://sure.readthedocs.io/en/latest/api-reference.html#look-like). I also read through the source code though, what they do is exactly the same as I (remove all the spaces using regex then lowercase the strings). However, I get your point, this is a short PR with little effort, so closing it is no big deal for me :sweat_smile:
Related issue
https://github.com/EastAgile/robber.py/issues/37
Description
Let's add this expectation to our code base:
This asserts if two strings are similar.
similar
means after removing all the spaces and got lowercased, the two strings are exactly the sameUsage