ruby - How to call a Method in a Cucumber - Step Definition -
i’m newbie cucumber framework. i’m trying phone call ruby method within of step definition. here how define method in lib/methods.rb
class test_class def create_test_scenario() puts "here!!!" end end
this how seek phone call method within of step definition:
and(/^i create scenarios$/) test_class.create_test_scenario end
i'm getting 'uninitialized constant test_class (nameerror)' when run test. ideas? thanks.
you haven't instantiated test_class object. example:
class test_class def create_test_scenario puts "here!!!" end end test_class.new.create_test_scenario # notice `new` method chained here #=> here!!!
errata:
here's link documentation explains initialize
method , how can utilize set object state on initialization.
for class (and module) names, ruby convention utilize camelcase
. example, testclass
instead of test_class
ruby cucumber
No comments:
Post a Comment