[rspec-users] WDYT, simple, anonymous story listeners?

Zach Dennis zach.dennis at gmail.com
Tue Aug 12 20:25:45 EDT 2008


Sometimes I don't have a full need to make a class to do something,
yet I want something readable and concise. This is influenced from the
joys of JavaScript.

Today I made this happen. Love it, like it, hate it, WDYT?

Spec::Story::Runner.register_listener FunctionalStruct.new(
  :run_started => lambda { |*args|
    Generate.user(:login => "normal user")
  },
  :run_ended => lambda { |*args|
      User.destroy_all
  },
  :method_missing => lambda { |*a| }
)


-- 
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com


More information about the rspec-users mailing list