[rspec-users] setup for stories

David Chelimsky dchelimsky at gmail.com
Wed Apr 16 18:44:41 EDT 2008


On Apr 16, 2008, at 6:22 PM, Joe Van Dyk wrote:

> I've got some code that should run before any stories execute.
> Where's a good place to put that?  (need to create a @sessions and
> @users hash)

The story framework has as simple listener API (not documented, but  
otherwise nice):

class StorySetupListener
   def run_started(num_scenarios)
     # do your stuff here
   end

   def method_missing(method, *args)
     # no-op
   end
end

Spec::Story::Runner.register_listener(StorySetupListener.new)

Give that a whirl.

Cheers,
David



More information about the rspec-users mailing list