Monday, November 10, 2014

What's A Pirate's Favorite Domain-Specific Language? ARRRRRRRSpec!

Hello. Thank you for joining me in my office. I called you here today because we really need to talk about RSpec.

That is the daydream I'm having in my head about RSpec's parents getting called in to a parent-teacher conference. I don't mean to alarm you, Mr. and Mrs*. RSpecsparents. It's not so much that RSpec has been misbehaving in class - I can tell RSpec is a really great kid, but I just haven't found a way to really connect with it. 

If RSpec's parents let it have a Facebook page (which they don't, because of the menace of cyber bullying), its About page would tell you that RSpec is a domain-specific language used to test things written in Ruby and tell you whether or not they work right. My About page would tell you that I've been trying to learn RSpec this week**. And then I might follow that up with, "...and it did not go suuuuuper awesome."

Author's Note: the following critiques are my impressions based on the resources I've found so far. I'd love to know of any resources that address any of these points.

Here's what I'm finding: 
  • There aren't that many free resources on RSpec out there. I'm trying to do this project with only free materials, but RSpec is challenging that. 
  • RSpec overhauled its syntax a couple years ago, from a syntax that says should all the time to one that says expect all the time. (That's clearly not a functional description, but is enough for you to know which one you're looking at.) Any free resource I have found that is explicitly a tutorial is teaching the should syntax (this doesn't make it useless - folks are still using it, so it still seems worthwhile to become familiar - I would like to start with best practices, though)
  • The documentation on RSpec is not particularly beginner-friendly, and assumes an underlying understanding of testing concepts - e.g. overall structure of tests and different contexts in which different types of matchers are more appropriate.
  • All the explicitly tutorial materials exclusively talk about RSpec in a TDD context. Test-driven development, where you write a test first, then write the code that passes the test, makes a lot of sense to me. I can see why there would be a big focus on it. However, it's not the only context in which RSpec is used, and so shouldn't be the only context in which it's taught. 
So, to turn that around a little bit, my wish list*** for RSpec teaching material would include a) an overview of testing concepts and contexts, b) a LOT of examples that are simple and explicit about what each piece of the test corresponds to which piece of the code being tested, and c) up-to-date syntax or both syntaxes (is that even the plural of syntax?) 

That said, I googled my arse off and fiddled with RSpec a whole bunch - the past couple of days have been replete with googling and fiddling (like at a techie bluegrass convention) - and have finally gotten some tests to pass! Huzzah! I suspect they're quite ugly, but I'm taking the win. I will take my hard-fought knowledge, and with it I shall test the remainder of my text adventure, then the mastermind and calculator programs I have written so far. 

Let me take this opportunity to knock on some wood, before the Tech Gods smite me down for my hubris, and make none of the things work anymore.

ps - I'll come back in a bit and post some of the better resources I have found. You just sit there clicking refresh until I do.

*I have attributed RSpec's fictional parentage to a heteronormative framework for the sake of narrative brevity, but it should noted that RSpec could just as easily have two mommies or two daddies or been raised by a gender indeterminate pack of wolves.

**This is not true. My About page says actually says that I was born in 1915, but that is not germane to RSpec.

***Yes, I realize that I don't actually have to wish for someone else to do it. I may need to write some of that myself - whatever I do, I will of course share it with you, darling readers.

No comments:

Post a Comment