[rspec-devel] rspec extensions

Brian Takita brian.takita at gmail.com
Thu Sep 20 01:05:27 EDT 2007

On 9/16/07, Ian Dees <undees at gmail.com> wrote:
> Hi, all.  Quoth Brian:
> > I think such a tagging feature would be useful in rspec core. To add
> > it to rspec core (trunk), I think the following objects need to be
> > touched (without seeing the code):
> > * Tagging object(s)
> > * Example.suite
> > * ExampleApi (describe, it, and tags methods)
> > * ExampleDefinition (tags method)
> > * Options (For non-rake command line arguments)
> > * OptionParser (For non-rake command line arguments)
> > * maybe SpecTask
> This to-do list sounds similar to the objects we had to modify or at
> least study for a similar project at work.  We've hacked a
> tagging-like option by using custom formatters that take parameters,
> something like:
> spec --format tag:foo --format tag:bar baz_spec.rb
> I think we mainly had to mess around with the parser because we're
> calling RSpec from our own command-line tool.
> We use it for batch vs. interactive tests (a couple of our tests
> require physically connecting a calibration cable or grabbing a
> printout from the printer), and we want to use it for English vs.
> non-language-specific tests.
> We could get rid of all our custom formatter cruft (and option parsing
> cruft) if we had tags.  Our code is a little baroque now.  (If I had
> it all to do over again, I would've used the -r option and just had my
> setup in different .rb files.)  But with every release of RSpec, I
> seem to be able to cut a few more kludges from my stuff -- the trend
> is definitely going in the right direction.
Great. I hope it continues :)
> How would a tags mechanism be different from the behaviour_type option
> that Aslak mentioned?  Is there documentation on behaviour_type?  I
> see a few examples of how to attach it to a "describe" block, but not
> much on what to do with it after that.
behaviour_type sets the class of the Behaviour. behaviour_type is used
in rspec on rails.

In the current release, behaviour_type can be set to HelperBehaviour,
ViewBehaviour, ModelBehaviour, or ControllerBehaviour. In trunk,
behaviour is renamed to example.

Right now, behaviour_type only allows one definition. A particular
example would need to be able to handle multiple Tags.
> --Ian
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel

More information about the rspec-devel mailing list