Skip to content

Instantly share code, notes, and snippets.

@robsquires
Created March 17, 2013 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robsquires/5182695 to your computer and use it in GitHub Desktop.
Save robsquires/5182695 to your computer and use it in GitHub Desktop.
For the given gherkin feature the standard step definitions are matching not problem. However, the @Transform is not being matched. Is the syntax correct?
for the given scenario:
Scenario: I can drill down by product line
Given I have searched for "light sources"
And I have selected the category "led"
When I select the product line "Track 3"
Then I should see products:
| name |
| Test Product 3 |
| Test Product 5 |
this is being matched:
/**
* @When /^I select the (category) "([^"]*)"$/
* @When /^I select the (product line) "([^"]*)"$/
* @Given /^I have selected the (category) "([^"]*)"$/
*/
public function filterByThe($filter, $value){)
BUT this is not being matched:
/**
* @Transform /product line "([^"]*)"/
*/
public function lookupProductLine($name){}
@everzet
Copy link

everzet commented Mar 17, 2013

Here's how transformations get applied:

  1. Arguments get extracted from regex scopes (category, product line + led, Track 3 in your case)
  2. Transformation regexes are applied to these already extracted arguments one by one.

Obviously, your product line "([^"]*)" transformation doesn't match any of category, product line, led or Track 3 strings.

Key misunderstanding of yours here is that this feature is called "Argument transformations", not "Step transformations" ;)

@robsquires
Copy link
Author

You're right, I misunderstood exactly that. I've changed this to:

/**
* @When /^I select the (product line "([^"]*)")$/
*/
public function selectTheProductLine(ProductLine $productLine){)

/**
* @When /^I select the (category "([^"]*)")$/
* @Given /^I have selected the (category "([^"]*)")$/
*/
public function filterByTheCategory(Category $category){)

...and works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment