Hello,
how can I execute some code after each step of a story. Is there some
kind of listener documentated.
Thank you in advance,
Armin
Hello,
how can I execute some code after each step of a story. Is there some
kind of listener documentated.
Thank you in advance,
Armin
On Dec 26, 2007 4:38 PM, Armin J.
[email protected] wrote:
Hello,
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)
The listener needs to respond to a variety of messages related to
steps and scenarios, so you’ll probably want to implement
method_missing to ignore the messages you’re not interested in.
HTH,
David
Hi!
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
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::StoryRunner
or --runner Spec::Story::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
Bye,
Kero.
Hello and happy new year,
David’s answer and some digging in RDoc of RSpec has lead to the
following code sceleton:
class Listener
def run_started(number_of_scenarios)
end
def run_ended
end
def story_started(title, description)
end
def story_ended(title, description)
end
def scenario_started(story_title, scenario_title)
end
def scenario_succeeded(story_title, scenario_title)
end
def scenario_failed(story_title, scenario_title, exception)
end
def scenario_pending(story_title, scenario_title, message)
end
def step_succeeded(kind_of_step, step_line, *args)
end
def step_failed(kind_of_step, step_line, *args)
end
def step_pending(kind_of_step, step_line, *args)
end
def collected_steps(*args)
end
end
Spec::Story::Runner.register_listener(Listener.new)
The above instance methods of Listener has to be implemented. The seem
to me self-explaining. Only the last one, Listener# collected_steps,
needs further investigation. But I have not needed it yet.
Hope this helps,
Armin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs