Discussion:
[Cucumber] Matching on a Phrase (not Word or String) with Cucumber 3.x Placeholders
(too old to reply)
Jeff Nyman
2018-02-23 21:09:13 UTC
Permalink
Raw Message
Hi all.

In demonstrations I had a feature spec like this:

Scenario: Simple Warp Calculations
* a basic trip to alpha centauri takes 4.3 years
* a basic trip to epsilon eridani takes 10.5 years

I realize this looks like an odd feature spec. This was done for
illustrative purposes but it is exactly how a business group wanted to word
it. This isn't about the Gherkin.

The step definition for this I used to use in Cucumber 2.x was:

Then(/^a basic trip to (.*) takes (.*) years$/) do |location, time|
on(WarpTravel).confirm_basic_trip_for(location).is(time)
end

With Cucumber 3.x, I realize this is now done with placeholder syntax:

Given("a basic trip to {word} takes {float} years") do |location, time|
on(WarpTravel).confirm_basic_trip_for(location).is(time)
end

However, I can't do {word} for alpha centauri because it's two words. I do
realize I can put "alpha centauri" and "epsilon eridani" in quotes and use
{string}. But science business users often don't like using quotes in these
contexts.

Is there the concept of a {phrase} as opposed to just a {word}? Or are
quotes the best option?

- Jeff
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
aslak hellesoy
2018-02-23 23:03:10 UTC
Permalink
Raw Message
Post by Jeff Nyman
Hi all.
Scenario: Simple Warp Calculations
* a basic trip to alpha centauri takes 4.3 years
* a basic trip to epsilon eridani takes 10.5 years
I realize this looks like an odd feature spec. This was done for
illustrative purposes but it is exactly how a business group wanted to word
it. This isn't about the Gherkin.
Then(/^a basic trip to (.*) takes (.*) years$/) do |location, time|
on(WarpTravel).confirm_basic_trip_for(location).is(time)
end
Given("a basic trip to {word} takes {float} years") do |location, time|
on(WarpTravel).confirm_basic_trip_for(location).is(time)
end
However, I can't do {word} for alpha centauri because it's two words. I do
realize I can put "alpha centauri" and "epsilon eridani" in quotes and use
{string}. But science business users often don't like using quotes in these
contexts.
Is there the concept of a {phrase} as opposed to just a {word}?
Not built-in, but you can define your own parameter type. Did you try that?
Aslak
Post by Jeff Nyman
Or are quotes the best option?
- Jeff
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
aslak hellesoy
2018-02-24 00:13:37 UTC
Permalink
Raw Message
Post by Jeff Nyman
Hi all.
Scenario: Simple Warp Calculations
* a basic trip to alpha centauri takes 4.3 years
* a basic trip to epsilon eridani takes 10.5 years
I realize this looks like an odd feature spec. This was done for
illustrative purposes but it is exactly how a business group wanted to word
it. This isn't about the Gherkin.
Then(/^a basic trip to (.*) takes (.*) years$/) do |location, time|
on(WarpTravel).confirm_basic_trip_for(location).is(time)
end
Given("a basic trip to {word} takes {float} years") do |location, time|
on(WarpTravel).confirm_basic_trip_for(location).is(time)
end
However, I can't do {word} for alpha centauri because it's two words. I do
realize I can put "alpha centauri" and "epsilon eridani" in quotes and use
{string}. But science business users often don't like using quotes in these
contexts.
Is there the concept of a {phrase} as opposed to just a {word}?
Not built-in, but you can define your own parameter type. Did you try that?
Aslak
Post by Jeff Nyman
Or are quotes the best option?
- Jeff
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...