News for hackers. Stuff that matters.
Re:My favourite Git commit (2019) by jspash on Sunday March 08, 2020 @02:56PM (#22519796)
I'm just curious but... did this actually fix anything other than the spec?

The reason I ask is that I find myself (with Rails particularly) spending an awful lot of time on maintaining tests that were written by a much younger and much less experienced developer (me, a few years ago).

And I've come to the slow realisation that a lot of what I was testing wasn't really important.

I'm not saying the author shouldn't have written the spec, or that the spec wasn't valuable. But maybe the true bug here was that rspec matchers don't honour utf-8 spaces and perhaps they should? I dunno. Just thinking out loud here.

Re:My favourite Git commit (2019) by hinkley on Sunday March 08, 2020 @03:18PM (#22519927)
Getting people to write tests is hard. Getting them to write matchers... it’s like you’re asking them to fly. Which is a shame because you can avoid so, so much test boilerplate by writing a high quality custom matcher.
Re:My favourite Git commit (2019) by jfkebwjsbx on Sunday March 08, 2020 @03:53PM (#22520139)
What do you mean by matcher?
Re:My favourite Git commit (2019) by allover on Sunday March 08, 2020 @04:07PM (#22520241)
> "matchers" [...] let you test values in different ways

Example docs for Jest's matchers: https://jestjs.io/docs/en/using-matchers

Generally speaking, if you use a specific matcher, you get a better (more informative) error message when the test fails.

Re:My favourite Git commit (2019) by jfkebwjsbx on Sunday March 08, 2020 @04:50PM (#22520521)
Ah, the common testing functions like `assert_equal`. Thanks!
Re:My favourite Git commit (2019) by hinkley on Monday March 09, 2020 @01:23PM (#22527320)
Right, and some APIs let you write your own. Getting a custom one to hand out actionable error messages is a bit tricky but quite worth it.
Re:My favourite Git commit (2019) by hashtagMERKY on Sunday March 08, 2020 @03:52PM (#22520136)
Not a software engineer, sorry. What’s a matcher? Google didn’t help.
Re:My favourite Git commit (2019) by hinkley on Sunday March 08, 2020 @04:47PM (#22520497)
Not to worry. Some test frameworks do not expose them, so people often don’t even to know to want for them. User allover did a respectable job of explaining.
Re:My favourite Git commit (2019) by antsar on Monday March 09, 2020 @08:57AM (#22524975)
IME (python webdev) most test frameworks do expose some form of this, but I’ve never heard them called “matchers”. So perhaps people know & use them, but not by that name.
Re:My favourite Git commit (2019) by hinkley on Monday March 09, 2020 @01:24PM (#22527343)
I mean expose the ability to write your own. When I first used them, I thought all frameworks allowed this, then bumped into some that didn't, or at least not in the popular version at the time.