[rspec-devel] Story implementation and custom matchers
dchelimsky at gmail.com
Wed Nov 7 23:45:36 EST 2007
On Nov 7, 2007 10:36 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Nov 7, 2007 10:33 PM, Jake Howerton <jake.howerton at gmail.com> wrote:
> > Is there currently a hook to load in custom matchers for the story runner?
> > I am looking for the equivalent to config.include(CustomMatchers) in
> > the normal rspec runner
> The only hook is :type => SomeClass. You could either subclass
> RailsStory and add your matchers to that, or just open it up and
> include modules with your matchers. I haven't tried either, but they
> *should* work.
I just tried the latter in a rails app and it works as expected. The
only danger is collisions as your helper/matcher libraries grow. If
that is not a concern, I'd say the simplest would be to add
matchers/helpers to modules and include them in RailsStory. Otherwise,
subclass it and use specific subs for each Story.
If you're not writing a rails app, then you'll need a base class of
some kind (by default, stories run in an instance of Object) to
include your modules in - or just define arbitrary objects with the
helpers/matchers embedded directly.
What we REALLY need is a way to define scoped matchers/helpers right
alongside the steps. Coming eventually ...
More information about the rspec-devel