[rspec-users] Cucumber: The Mysteries of Before(), After(), World() etc

aslak hellesoy aslak.hellesoy at gmail.com
Thu Nov 13 10:28:21 EST 2008


On Thu, Nov 13, 2008 at 3:59 PM, Peter Jaros <peter.a.jaros at gmail.com> wrote:
> On Wed, Nov 12, 2008 at 8:59 AM, David Chelimsky <dchelimsky at gmail.com> wrote:
>> On Wed, Nov 12, 2008 at 7:30 AM, aslak hellesoy
>> <aslak.hellesoy at gmail.com> wrote:
>>> World do
>>>  world = Object.new
>>>  world.extend(Logging::Logger)
>>>  world
>>> end
>>
>> World do
>>  returning Cucumber::Rails::World do |world|
>>    world.extend(Logging::Logger)
>>  end
>> end
>
> It would be really nice to be able to do:
>
> World do |world|
>  returning world do |w|
>   w.extend(Logging::Logger)
>  end
> end
>
> This way steps files could extend the world by adding to a chain,
> agnostic of the nature of the original world object.
>

You *may* want to be in control over the world type (class). For
example, in Rails the world instance is a
ActionController::Integration::Session instance (off the top of my
head) and in vanilla Cucumber it is Object. what if you want to change
that?

Maybe Cucumber could send in a world instance it *thinks* is the one
you want (allowing what you suggest (and allow the user to instantiate
a different class if they want to).

# I'm happy with the suggested type
World do |world|
  returning world do |w|
    w.extend(Logging::Logger)
  end
end

# I want my own type!
World do
  world = MyType.new
  returning world do |w|
    w.extend(Logging::Logger)
  end
end

I didn't see a ticket yet, so please add my comment or link to mail
archive for this thread when you create the ticket.

Cheers,
Aslak

> Peter
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list