Raisus Raisus - 1 year ago 80
Ruby Question

ruby cucumber - step undefined message but step exists in step_definitions

I'm currently getting an unusual error message in that during the run of my BDD scripts, I get the following response when running through the command line:

Feature: As a user I want to purchase a mobile on a monthly plan

Scenario: Buy a pay monthly phone
Given I am on the Store Homepage
When I click on the Mobile Phones roundel link
And I select a "Apple" "Iphone 6s"
-->And I select the "1GB+AYCE min" price plan<--
Then I can complete my order

1 scenario (1 undefined)
5 steps (1 skipped, 1 undefined, 3 passed)

(The one in arrows is the one highlighted in my command line as being undefined)

However, in my .rb script under step_definitions folder, I have the following:

Given (/^I am on the Store Homepage$/) do
When (/^I click on the Mobile Phones roundel link$/) do
When (/^I select a "Apple" "Iphone 6s"$/) do
When (/^I select the "1GB+AYCE min" price plan$/) do
Then (/^I can complete my order$/) do

I'm not sure why this cucumber script is missing out a step, but it's infuriating me to no end. Can anyone help?

EDIT: Off the back of that, if anyone can also answer why it's not showing me the snippets that it's expecting, that'd be great.

Answer Source

You should not be creating a step for each plan.

When (/^I select the "([^"]*)" price plan$/) do |plan|
  select plan
  when "1GB+AYCE min"
    # do something
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download