[rspec-users] New generated RSpec Video, demonstrating a GTK app

Kero rspec-users at kero.tmfweb.nl
Thu Feb 28 23:18:06 EST 2008

Hi all,

With some time spent last Tue on the nyc.rb hackfest, I have a second video
today of my endeavours with RSpec and recordings. It shows a handful
of When&Then steps, with the accompanying GTK2 GUI executing these steps.

One nasty thing about Gtk (and virtually all other toolkits) is that
they think they are all-important. You have to call Gtk.main, which only
returns when the GUI is dead. Of course, my test is all-important here.
The consequence is that I can not rely on the default exit hooks of rspec.
we get:
  Thread.new {

where I need to register my own story runner, define the tests and run it:
  def run_tests
    narrator = Narrator.new({}, "here")

    sr = Spec::Story::Runner::ScenarioRunner.new
    story_r = Spec::Story::Runner::StoryRunner.new(sr)
    story_r.add_listener narrator
    Spec::Story::World.add_listener narrator
    story_r.instance_eval {

where Narrator is my class with step_upcoming, step_succeeded, method_missing
and then a few; where define_tests is a method that contains
   Story() { Scenario() { ... } }

Note that I need to register my narrator _twice_ to get all methods
called (bug? should I file a ticket?).

If I use
   Spec::Story::Runner.register_listener narrator
instead, the World / steps are executed, but the runner / scenario_started
callbacks are not. Unexpectedly, I get a free PlainTextFormatter (wtf?)

I have no qualms with a good formatter like PlainText, that frees me
from redoing the work. But, when I try to register one by hand, in the
way that seems to be done in rspec/lib/spec/story/runner.rb :
   Spec::Story::Runner.register_listener Spec::Runner::Formatter::Story::PlainTextFormatter.new({}, STDOUT)
I get
   rspec/lib/spec/runner/formatter/base_text_formatter.rb:97:in `colour?': undefined method `colour' for {:colour=>false}:Hash (NoMethodError)
which isn't neither too weird, nor too comforting. Any hints for a shortcut,
before I fake option parsing (or decide I want the arguments from my own command-line,

And then of course, what you've been reading/waiting for:
(only 5.5 MB, including snippets of the code that generated it).

mencoder does not really play nice and synchronization of audio+video
has been tweaked by hand (that's not necessary when playing directly
from running the story, of course; look at the clock in the bottom
right and you'll understand), and it is still a mess near the end.
So I'm still looking for alternative tools to do speech synthesis (sox
refuses to play some of the shorter espeak wavfiles, I bet sox is right
and espeak is wrong) and encoding video.


More information about the rspec-users mailing list