I’m working on a series going over the source code for rspec, and I ran
into
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.
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
implemented.
Along the way, I figured I would ask questions that were confusing to
me.
So, please bear with me and please please please do not take this as
criticisms/attacks]
I expected to see SharedExampleGroup < ExampleGroup, but, instead, I saw
SharedExampleGroup < Module. This is incredibly confusing to me. I
realize
that they don’t even need to have any relationship to each other since
they
get their shared functionality through the module ExampleGroupMethods,
but
it still seems a bit odd to me that they don’t have a hierarchical
relationship.
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
anyone is
interested: It looks like I’ll be able to get about a post a week on it.
part 3:
http://www.coreyhaines.com/coreysramblings/2007/12/22/ARubyNewbieLooksThroughRSpecPartIIIDescribeRedux.aspx
part 4: I’m working on this, which is where I noticed the
ExampleGroup/SharedExampleGroup thing.
-Corey