Derek Ekins
Derek Ekins

Reputation: 11391

Extending cucumber with modules and accessing Before/After hooks

I am trying to write a generic module to extend the World class. I need to access the Before and After hooks from within the module. I am doing this by using the extended method but Before/After does not seem to be available at this point.

module MyWorld
  def MyWorld.extended(obj)
    obj.Before do
      # this doesn't work
    end
  end
end

Is there another way to access these hooks?

Upvotes: 1

Views: 889

Answers (1)

Derek Ekins
Derek Ekins

Reputation: 11391

Found out how to do it:

module MyWorld
  def MyWorld.extended(obj)
    Main.Before do
      # some stuff
    end

    Main.After do
      # some other stuff
    end   
  end
end

Upvotes: 1

Related Questions