Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:39:52+00:00 2026-06-07T20:39:52+00:00

I have the following Transform: Transform /^([^]+) Phase$/ do |name| # Returns the phase

  • 0

I have the following Transform:

Transform /^"([^"]+)" Phase$/ do |name|
  # Returns the phase named 'name',
  # or raises an exception if it doesn't exist
end

which works with step definition like this:

Then /("(?:[^"]+)" Phase) should do something/ do |phase|
  # Should fail if the specified phase doesn't exist
end

I have also the following step definition which uses the same "([^"]+)" Phase pattern:

Given /("([^"]+)" Phase) follows ("([^"]+)" Phase)/ do |pre, post|
  # Should create the specified phases 
end

Here I don’t want the step definition to fail if the specified phases doesn’t exist. I would like to create the phases instead.

I would like to create a Transform that will create the phase for me to DRY up the step definitions a bit, but I can’t do so because I already have the Transform mentioned above which has exactly the same regexp.

Basically, I would like to create the phase if it is a Given step, and raise fail if it is not.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:39:55+00:00Added an answer on June 7, 2026 at 8:39 pm

    If the regexps are the same, then you don’t really have an option to differentiate the behaviour. Determining whether or not you’re in a Given step might be possible, but even if so, it would be some very well-hidden magic with the potential to surprise future readers and scenario authors…

    The easiest, and most intention-revealing way to do this would be to explicitly state the nature of the Phrase in the step language, then you can have 2 clearly-separated transforms e.g.

    EXISTING_PHASE = Transform /^existing Phase "([^"]+)"$/ do |phase|
        # raise error if it doesn't exist
    end
    
    UNEXISTING_PHASE = Transform /^unknown Phase "([^"]+)"$/ do |phase|
        # create the phase if it doesn't exist
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following List which contains the following collection. How i can transform
I have the following in an XLST document <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:fo=http://www.w3.org/1999/XSL/Format xmlns:str=http://xsltsl.org/string xmlns:dt=http://xsltsl.org/date-time
I have a string of style transform given in the following way : matrix(0.312321,
I have the following jQuery script to transform a checkbox into a jQuery-UI button
Lets say i have the following web page: <html> <body> <div class="transform"> <span>1</span> </div>
I have the following code defining a Functor template and the function running_op, which
I have the following xslt to transform data into a JQuery-accepted format. However, because
I have the following line of xml that I'm trying transform using XSLT but
I have a following XML structure that I need to transform: <recordset rowCount=68 fieldNames=ITEM,ECL,LEAD_TIME
I have the following function in C++ managed (ref) class: public static void Transform(Bitmap^

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.