36 min

382: Domain-Specific Languages The Bike Shed

    • Technology

Joël has been integrating a third-party platform into a testing pipeline...and it has not been going well. Because it's not something she usually keeps up-to-date with, Stephanie is excited to learn about more of the open-source side of things in Ruby, what's new in the Ruby tooling world, and what folks are thinking about regarding the future of the language.


Today's topic is inspired by an internal thoughtbot Slack thread about writing a custom matcher for Rspec. Stephanie and Joël contrast DSLs vs. Object APIs and also talk about:



CanCanCan vs Pundit
RSpec DSL
When is a DSL helpful?
Why not use both DSLs & Object APIs?
Extensibility
When does a DSL become a framework?




This episode is brought to you by Airbrake. Visit Frictionless error monitoring and performance insight for your app stack.





RubyKaigi 2023
Mystified by RSpec’s DSL? by Jason Swett
Building Custom RSpec Matchers with Regular Objects
FactoryBot
Writing a Domain-Specific Language in Ruby by Gabe Berke-Williams
Capybara
Acceptance Tests at a Single Level of Abstraction
CanCanCan
Pundit
Discrete Math and Functional Programming


Transcript:


STEPHANIE: Hello and welcome to another episode of The Bike Shed, a weekly podcast from your friends at thoughtbot about developing great software. I'm Stephanie Minn.


JOËL: And I'm Joël Quenneville. And together, we're here to share a little bit of what we've learned along the way.


STEPHANIE: So, Joël, what's new in your world?


JOËL: I've been integrating a third-party platform into our testing pipeline for my client. It has not been going well. We've been struggling a little bit, mostly just because tests just kind of crash. Our testing pipeline is pretty complex. It's a lot of one script, some environment variables, does a few things, shells out to another script, which is in a different language. Does a few more things, shells out to another script, maybe calls out to rake, calls out to a shell script. There are four or five of these in a chain, and it's a bit of a mess.


Somewhere along in there, something is not compatible with this third-party service that we're trying to integrate with. I was pairing this week with a colleague. And we were able to reproduce a situation where we were able to get a failure under some conditions and a success under other conditions. So these are basically, if we run the whole chain of scripts that call each other from the beginning, we know we get a failure. And if we skipped entirely the chain of scripts that set up things and then just manually try to invoke a third-party service, that works.


And so now we know that there's something in between that's incompatible, and now it's just about narrowing things down. There are a few different approaches we could take. We could try to sort of work our way forward. We know a known point where it breaks and then just try to start the chain one step further and see where it fails. We could try to get fancy and do a binary search, like split it in half and then half and half again.


We ended up doing it the other way, where we started at the end. We had our known good point and then just stepping one step back and saying, okay, now we introduce the last script in the chain. Does that work? Okay, that pass is great. Let's go one step further; two scripts up in the chain. And at some point, we find, okay, here's the one script that fails. Now, what is it within this script? And it was a really fun debugging session where we were just narrowing things down until we found the source of the bug.


STEPHANIE: Wow, that sounds pretty complicated. It just seems like there are so many layers going on. And it was really challenging to pinpoint where the source of the issue was.


JOËL: Definitely. I think all the layers made it really complicated. But having a process that we could follow and then kind of narrowing it down made it almost mechanical to figure out where the bug was once we got to a point where we had a k

Joël has been integrating a third-party platform into a testing pipeline...and it has not been going well. Because it's not something she usually keeps up-to-date with, Stephanie is excited to learn about more of the open-source side of things in Ruby, what's new in the Ruby tooling world, and what folks are thinking about regarding the future of the language.


Today's topic is inspired by an internal thoughtbot Slack thread about writing a custom matcher for Rspec. Stephanie and Joël contrast DSLs vs. Object APIs and also talk about:



CanCanCan vs Pundit
RSpec DSL
When is a DSL helpful?
Why not use both DSLs & Object APIs?
Extensibility
When does a DSL become a framework?




This episode is brought to you by Airbrake. Visit Frictionless error monitoring and performance insight for your app stack.





RubyKaigi 2023
Mystified by RSpec’s DSL? by Jason Swett
Building Custom RSpec Matchers with Regular Objects
FactoryBot
Writing a Domain-Specific Language in Ruby by Gabe Berke-Williams
Capybara
Acceptance Tests at a Single Level of Abstraction
CanCanCan
Pundit
Discrete Math and Functional Programming


Transcript:


STEPHANIE: Hello and welcome to another episode of The Bike Shed, a weekly podcast from your friends at thoughtbot about developing great software. I'm Stephanie Minn.


JOËL: And I'm Joël Quenneville. And together, we're here to share a little bit of what we've learned along the way.


STEPHANIE: So, Joël, what's new in your world?


JOËL: I've been integrating a third-party platform into our testing pipeline for my client. It has not been going well. We've been struggling a little bit, mostly just because tests just kind of crash. Our testing pipeline is pretty complex. It's a lot of one script, some environment variables, does a few things, shells out to another script, which is in a different language. Does a few more things, shells out to another script, maybe calls out to rake, calls out to a shell script. There are four or five of these in a chain, and it's a bit of a mess.


Somewhere along in there, something is not compatible with this third-party service that we're trying to integrate with. I was pairing this week with a colleague. And we were able to reproduce a situation where we were able to get a failure under some conditions and a success under other conditions. So these are basically, if we run the whole chain of scripts that call each other from the beginning, we know we get a failure. And if we skipped entirely the chain of scripts that set up things and then just manually try to invoke a third-party service, that works.


And so now we know that there's something in between that's incompatible, and now it's just about narrowing things down. There are a few different approaches we could take. We could try to sort of work our way forward. We know a known point where it breaks and then just try to start the chain one step further and see where it fails. We could try to get fancy and do a binary search, like split it in half and then half and half again.


We ended up doing it the other way, where we started at the end. We had our known good point and then just stepping one step back and saying, okay, now we introduce the last script in the chain. Does that work? Okay, that pass is great. Let's go one step further; two scripts up in the chain. And at some point, we find, okay, here's the one script that fails. Now, what is it within this script? And it was a really fun debugging session where we were just narrowing things down until we found the source of the bug.


STEPHANIE: Wow, that sounds pretty complicated. It just seems like there are so many layers going on. And it was really challenging to pinpoint where the source of the issue was.


JOËL: Definitely. I think all the layers made it really complicated. But having a process that we could follow and then kind of narrowing it down made it almost mechanical to figure out where the bug was once we got to a point where we had a k

36 min

Top Podcasts In Technology

Lex Fridman Podcast
Lex Fridman
Acquired
Ben Gilbert and David Rosenthal
All-In with Chamath, Jason, Sacks & Friedberg
All-In Podcast, LLC
Darknet Diaries
Jack Rhysider
Hard Fork
The New York Times
The Gatekeepers
BBC Radio 4

More by thoughtbot

The Bike Shed
thoughtbot
Giant Robots Smashing Into Other Giant Robots
thoughtbot
Crossroads
thoughtbot
Tentative
thoughtbot
Reboot
thoughtbot
Build Phase
thoughtbot