[rspec-users] executing code after each step of a story

Kero van Gelder rspec-users at kero.tmfweb.nl
Mon Dec 31 12:54:00 EST 2007


After a bit of digging in runners, I found that I need a formatter, really.
now --format FORMAT:WHERE is explained properly by --help.
--runner otoh, is not; see below.

For the purpose of recording a user story (demo, webdemo), I run espeak
for each step and then some. It seems to me, a formatter is the correct
thing to use for this, but it demands a WHERE parameter that I am not
going to use, as such (I need to store audio snippets and combine with
screenshots into video; grabbing screens is
not formatting anymore; a listener would be better, see below).
Would it be an idea to not stop executing when I specify "-f Speaker:"
which indicates I know I would need the WHERE, but actually don't?

But worse, when I specify -f p -c -f Speaker, I get my speaker to speak
*before* the coloured text is printed. This is not nice for a live demo,
since the customer can not read along.

When I specify -f Speaker -f p -c, I get my speaker to get one step ahead
of the normal formatter (it speaks, it speaks, the prints, speaks, prints
and prints). I am confused as to why that happens.

> > how can I execute some code after each step of a story. Is there some
> > kind of listener documentated.
> Very little is documented, and Story Runner is still considered
> experimental (i.e. API's subject to change), but here is what you can
> do with the 1.1.1 release:
> World.add_listener(mylistener)

Found that before. Together with
 - Spec::Story::Runner::ScenarioRunner#add_listener
 - Spec::Story::Runner::StoryRunner#add_listener

This is at least inconsistent; where is the StepRunner?
"World" really seems too generic a name.

Also, a formatter, though it hooks into similar things, is not a listener.
What's the relation? If I do not know the relation, I can never decide what the
appropriate time is to make a screenshot.

And why, when I specify  --runner Spec::Story::Runner::StoryRunner
or --runner Spec::Story::Runner::ScenarioRunner do things break?
(or, perhaps, what is a custom runner supposed to run?)

I need to mess with my own runner when I want to see gtk things happening
on screen (which would be even cooler for demoes). This is the reason I started
messing with runners and only noticed the formatters much later...
I succeeded in that, though it is not pretty (have to call exit myself),
is there any way to disable the at_exit registered stuff?

to be clear, I have Ruby code like
  require 'spec'
  Story { Scenario { When {} Then {} } }
and run it with
  `ruby that_code.rb`
(whereas `spec that_code.rb` is very silent; a warning would be nice)

I'll post some videos and code when I'm really done :)


More information about the rspec-users mailing list