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

aslak hellesoy aslak.hellesoy at gmail.com
Wed Aug 13 11:00:02 EDT 2008

On Wed, Aug 13, 2008 at 4:50 PM, Zach Dennis <zach.dennis at gmail.com> wrote:
> On Wed, Aug 13, 2008 at 8:29 AM, aslak hellesoy
> <aslak.hellesoy at gmail.com> wrote:
>> On Wed, Aug 13, 2008 at 2:25 AM, Zach Dennis <zach.dennis at gmail.com> 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")


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

More information about the rspec-users mailing list