Try the following way:
Before do |scenario|
...
# step counter
@step_count = 0
end
AfterStep do |step|
current_feature = if scenario.respond_to?('scenario_outline')
# execute the following code only for scenarios outline (starting from the second example)
scenario.scenario_outline.feature
else
# execute the following code only for a scenario and a scenario outline (the first example only)
scenario.feature
end
# call method 'steps' and select the current step
# we use .send because the method 'steps' is private for scenario outline
step_title = current_feature.feature_elements[0].send(:steps).to_a[@step_count].name
p step_title
# increase step counter
@step_count += 1
end
It has to work fine for both 'scenario' and 'scenario outline'