World vs Include in cucumber/ruby

734 Views Asked by At

Can anyone tell me the difference between include and World? in my env.rb file I want to expose a module, and I can't really see the difference between the approaches...

Module example:

module Test do
  ...
end

In my env.rb file:

World(Test)

or

include Test

Besides that, can anyone state the pros/cons of using World rather than include in cucumber/ruby?

1

There are 1 best solutions below

1
Jeff Price On

World(Test) is the preferred method.

The purpose to using World(Test) is that you don't pollute the global namespace yet you still have all the functionality of that module available in your stepdefs.