0

I recall there being a way to execute a step from within another step using spinach.

As I recall, such a step would appear similar to the following:

...
step "I create a patient as a facility's administrator" do
  %Q{ Given I am a facility's administrator }
  %Q{ Given I create a patient }
end
...

Found .execute(step) but haven't had any luck getting at a Step object to send as argument. How can I execute steps from within another step? Help is appreciated.

rthbound
  • 1,323
  • 1
  • 17
  • 24
  • can find desired step in ObjectSpace, but surely spinach offers a more direct way to call & execute a step. – rthbound Jan 16 '13 at 22:16

1 Answers1

1

execute is an internal method that shouldn't be used from a feature. If you want to execute a step from another step you do have to underscore it. Spinach maintainers suggest extracting the logic in "I am a facility's administrator" and "I create a patient" step to another method, and calling this very method from other steps.

step "I create a patient as a facility's administrator" do
  log_as_facility_admin
  create_patient
end

def log_as_facility_admin
  # something
end

def create_patient
  # something
end

source: https://github.com/codegram/spinach/issues/132

Heartcroft
  • 1,672
  • 2
  • 19
  • 31