On Wed, Aug 13, 2008 at 11:00 AM, aslak hellesoy <[EMAIL PROTECTED]> wrote: > On Wed, Aug 13, 2008 at 4:50 PM, Zach Dennis <[EMAIL PROTECTED]> wrote: >> On Wed, Aug 13, 2008 at 8:29 AM, aslak hellesoy >> <[EMAIL PROTECTED]> wrote: >>> On Wed, Aug 13, 2008 at 2:25 AM, Zach Dennis <[EMAIL PROTECTED]> wrote: >>>> 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? >>>> >>> >>> As mentioned earlier on the RSpec development list, we're considering >>> replacing the Story runner with a new implementation: >>> >>> http://github.com/aslakhellesoy/cucumber >>> http://gojko.net/2008/08/06/cucumber-next-generation-ruby-bdd-tool/ >>> http://www.nabble.com/-ANN--Cucumber-td18876816.html >>> >>> >>> I'd rather see a similar construct for Cucumber, which already is >>> (IMHO) much better than the Story Runner. >>> >>> >>> Before(:all) do >>> end >>> >>> After(:all) do >>> end >>> >>> (per-scenarion Before/After is already implemented). >>> >> >> When you say "rather see a similar construct" -- are you referring to >> having the Before(:all) and After(:all) capability that you posted, or >> something similar to what I posted with using a FuncionalStruct as an >> argument to register a listener on the existing StoryRunner (a >> clear/concise way to hook-in with those one off listeners) ? >> > > By "similar construct" I meant something that achievs the same goal > (running pieces of code at different times during the run). > > I suggested Before(:all) and After(:all) because: > > * It's a familiar concept from RSpec examples > * It's much easier to read/write > > Compare these: > > # Your suggestion > Spec::Story::Runner.register_listener FunctionalStruct.new( > :run_started => lambda { |*args| > Generate.user(:login => "normal user") > } > ) > > # My suggestion: > Before(:all) do # We can pass args to the block if we want to > Generate.user(:login => "normal user") > end >
Before/After is definitely much cleaner, although I'm not a fan of more global namespace pollution, but it may not be a problem in practice (and/or maybe it's scoped in to another namespace like Feature::Before(:all)) Are you thinking of allowing for multiple Before/After(:all) blocks? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users