Topic: how to write cucmber step into a step definition

Hi!

A few days ago, i had seen a cucumber test, where inside the step definition they had use cucumber text...
Is there any special syntax for it? Cause its not working for me.

My one looks like this (/features/step_definitions/advertisements_steps.rb):

Then /^I should have (\d+) "([^"]*)" templates$/ do |value, selector|
  And I follow "#{selector}_templates_selector"
  .
  . 
  .
end

And i get this error:

Then I should have 2 "pre_roll" ad_templates                      # features/step_definitions/advertisements_steps.rb:9
  undefined method `follow' for #<Cucumber::Rails::World:0x5f9006a> (NoMethodError)
  ./features/step_definitions/advertisements_steps.rb:10:in `/^I should have (\d+) "([^"]*)" ad_templates$/'
  features/advertisements/create_advertisements.feature:128:in `Then I should have 2 "pre_roll" ad_templates'

And I have this in the /features/step_definitions/web_steps.rb:

When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
  with_scope(selector) do
    click_link(link)
  end
end

Re: how to write cucmber step into a step definition

Ok, i found the answer!

Then /^I should have (\d+) "([^"]*)" ad_templates$/ do |value, selector|
  And %{I follow "#{selector}_templates_selector"}
end

So you need to make it into a string...