I’m working on a series going over the source code for rspec, and I ran
something interesting with ExampleGroup and SharedExampleGroup. I was
wondering if anyone could shed light on it.
[NOTE: I’m working through the code for my own edification in learning
Ruby has some features that I think are incredibly cool, so I’m using a
concrete implementation (RSpec) as a learning tool to see them
Along the way, I figured I would ask questions that were confusing to
So, please bear with me and please please please do not take this as
I expected to see SharedExampleGroup < ExampleGroup, but, instead, I saw
SharedExampleGroup < Module. This is incredibly confusing to me. I
that they don’t even need to have any relationship to each other since
get their shared functionality through the module ExampleGroupMethods,
it still seems a bit odd to me that they don’t have a hierarchical
If there is some hidden meaning, I’d love to hear it. I’ll post it as an
update to the blog entry, too.
Oh, and here are the links to the first few parts of the series if
interested: It looks like I’ll be able to get about a post a week on it.
part 4: I’m working on this, which is where I noticed the