0

I'm working with cucumber/ruby and I wanted to create a new module with some methods to use them in my step definitions.

I was reading how to do this here, https://github.com/cucumber/cucumber/wiki/A-Whole-New-World. But when I've tried the following I get an error:

  • create the new module under /root_location/lib/new_module.rb
  • create the module as:

.

module Newmodule
  def here
    puts "here"
  end
end
World(Newmodule)

However, when I then try to use the 'here' method from my steps definition, I just get:

undefined local variable or method `here' for # (NameError)

Any idea what I am doing wrong?

mickael
  • 2,033
  • 7
  • 25
  • 38
  • Why the cucumber-jvm tag? Your question is ruby focused not Java. – MikeJRamsey56 Feb 24 '17 at 21:12
  • Because as you can see from the answer below, it is NOT a ruby question, it has to do with the cucumber framework... so I guess that's always the case regarding of the language. – mickael Feb 27 '17 at 11:55
  • That answer wouldn't work for cucumber-jvm. You need to define glue directories. See for example http://stackoverflow.com/questions/17491989/cucumber-options-annotation – MikeJRamsey56 Feb 28 '17 at 13:54

1 Answers1

0

The module needs to be located in features, otherwise it won't be added into World. Cucumber does not look outside of features for anything unless you specifically tell it to.

Put this code either in features/support or features/step_definitions

diabolist
  • 3,990
  • 1
  • 11
  • 15
  • Thank you diabolist, I didn't know that. Knowing that, I created a file.rb under support, where I required the ruby file that I've got in my library and exported to the World from here. Many thanks! – mickael Feb 24 '17 at 14:51