[rspec-devel] BehaviourRunner and ExampleSuite

aslak hellesoy aslak.hellesoy at gmail.com
Mon Sep 24 04:38:18 EDT 2007


On 9/24/07, Brian Takita <brian.takita at gmail.com> wrote:
> On 9/22/07, Brian Takita <brian.takita at gmail.com> wrote:
> > On 9/22/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> > > The CHANGELOG says "Behaviour subclasses Test::Unit::TestCase".
> > > However, when I look in the code, the only subclass of TestCase is
> > > Example. There doesn't seem to be a Behaviour class at all anymore,
> > > but there are plenty of variables in the code named 'behaviour'
> > >
> > > For a long while we have been referring to "it" blocks as "examples",
> > > and they correspond to test_* methods in xUnit speak. Further, we used
> > > to call the describe blocks "behaviours" and they correspond to Test
> > > classes in xUnit speak.
> > >
> > > But now it looks like an "example" is analogous to a Test class?!?!
> > Currently Example is the Example instance and Behaviour is the Example
> > class. There is also a SharedBehaviour, which is a Module.
> >
> > Both the Example Class and SharedBehaviour include ExampleApi. It
> > seems like ExampleApi should be renamed to Behaviour.
> >
> > I think ExampleCallbacks can be merged into ExampleApi.
> >
> > ExampleDefinition is used by both SharedBehaviour and the Example
> > class. Example is the actual instance. It is created from an
> > ExampleDefinition.
> >
> > ExampleFactory probably should be renamed back to BehaviourFactory.
> > What do you think?
> >
> > ExampleMatcher should be renamed back to BehaviourMatcher and
> > ExampleMatcher#example_description and should be removed as it doesn't
> > seem to be used anymore.
> >
> > ExampleRunProxy is used by ExampleSuite run the Example block.
> >
> > ExampleShouldRaiseHandler handles should_raise options.
> >
> > ExampleSuite runs the Examples for the Example class.
> I have resolved the issues with these "Example" objects, except the
> ExampleMatcher, which was being used after all. I refactored it,
> though.
>
> I also removed the BehaviourRunner. There is only one call chain now,
> which is through Test::Unit::AutoRunner.
> This resolves the prepare being called several times issue.
>
> $behaviour_runner is replaced by $rspec_options.
> The prepare, run, and finish methods got moved to Options. Options
> seems like the wrong name for that object now, since it does actions
> such as running the examples.
> I've had good success with this "central" object in several projects,
> as it has centralized the internal state of the library.
>
> Some names I've used in the past is Registry, Space, Manager (eww),
> and Context (with rspec, there is a domain name conflict).
>
> The ExampleSuite object is largely untouched, and still needs to be refactored.
> Rspec adds two callbacks to the TestRunnerMediator object. The
> callbacks call the Options#prepare and Options#finish methods.
>
> How does everything look? Are there other areas of confusion?
>

The --runner option is gone. I'm on a project that relies on this
feature. We use RSpec to run Watir, and on a single machine it takes 2
hours. With a custom runner (in the Spec::Distributed project on
rspec-ext.rubyforge.org) we're able to run in parallel in 20 minutes.

Needless, to say - we're absolutely dependent on the --runner command
line switch that you just removed. Please put it back.

I realise this will mean that the Test::Unit runner and Behaviour
runner duplication problem is not solved, but we cannot just remove
features nilly willy.

Aslak

> Thanks,
> Brian
> > >
> > > There are 9 (!) example_* files and it's virtually impossible to tell
> > > where responsibilities are. Although I'm against extensive
> > > documentation in code explaining how the code works internally
> > > (because code should be self documenting) I think we're now at a point
> > > where we need to add comments or clean things up bigtime.
> > I think things should be cleaned up to be more understandable.
> > The previous versions of rspec were very difficult to understand too.
> > There were a number of things in the wrong places that have been
> > untangled, and there is still more work to do.
> > Since things are different, this is a great opportunity to see it from
> > the eyes of unfamiliarity and make it easier to grok.
> >
> > >
> > > I'm really confused.
> > >
> > > On 9/22/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I've noticed that BehaviourRunner#prepare is invoked via two different chains:
> > > >
> > > > bin/spec -> CommandLine#run -> BehaviourRunner#run -> BehaviourRunner#prepare
> > > > test/unit/testsuite.rb -> ExampleSute#run -> BehaviourRunner#prepare
> > > >
> > > > In one single run, #prepare gets called twice, and returns the second
> > > > time because of the @already_prepared check.
> > > >
> > > > This is all quite confusing to me, and the number of delegators in
> > > > ExampleSuite makes it even more confusing. Now that we're using
> > > > Test::Unit's runner it occurs to me that we should get rid of our own
> > > > "runner" stuff, but there still seems to be a lot of redundancy. The
> > > > code is plain hard to understand.
> > > >
> > > > You who've been involved in the Test::Unit refactoring - are you
> > > > planning to simplify things more and get rid of our own runner?
> > > >
> > > > Aslak
> > > >
> > > _______________________________________________
> > > rspec-devel mailing list
> > > rspec-devel at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/rspec-devel
> > >
> >
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the rspec-devel mailing list