--
E: [1]steve-***@public.gmane.org
T: +44 7919 337 463
[2]http://tooky.co.uk | [3]http://kickstartacademy.io |
[4]https://twitter.com/tooky
On Fri, 27 Jun 2014, at 03:19 PM, aslak hellesoy wrote:
On Fri, Jun 27, 2014 at 2:03 PM, Rob Park
<[5]robert.d.park-***@public.gmane.org> wrote:
On Fri, Jun 27, 2014 at 7:28 AM, aslak hellesoy
<[6]aslak.hellesoy-***@public.gmane.org> wrote:
On Fri, Jun 27, 2014 at 7:51 AM, Paolo Ambrosio
<[7]paolo-***@public.gmane.org> wrote:
On 26 Jun 2014 21:50, "aslak hellesoy"
Post by aslak hellesoyRegular expressions are powerful. They are also ugly
Yes, they are ugly, especially in languages where
backslashes need to be escaped.
Post by aslak hellesoyand many people struggle with them.
Very sad but true.
Post by aslak hellesoyI'd like to introduce an alternative to regular expressions
for step definitions: Turnip expressions [3]. (We'd still
support regular expressions).
Post by aslak hellesoyThe source code is here [4]. They are also supported in
Behat, source here [5].
Post by aslak hellesoyWhat do people think? Welcome addition?
I like it.
How would someone specify the expression type in step
definitions?
For languages that have a literal syntax for regular
expressions it's a non-issue. I think the only languages that
don't have this are Java, C# and C.
For those languages, it would be nice if we could use // as a
convention:
"/something/" => Regexp
"something" => Turnip
However, that will cause a lot of backwards incompatibility
problems, so we can't do that.
Do you think we could use a heuristic based on what's in the
string?
"I have (.*) cukes in my belly" => Regexp, because of '('
"I have :n cukes in my belly" => Turnip, because of ':'
Would we need to be able to escape the '(' and the ':',
respectively? i.e. \( \:
You mean if you want to use '(' and ':' literally? For example:
Then /I should see \:-\)/ do
end
I suppose we'd have to escape them, yes, but it sounds like a
pretty contrived case.
I haven't studied the existing Turnip Expression
implementations in detail. We should probably come up with a
spec and document it.
I have started a page here:
* [9]https://github.com/cucumber/cucumber.github.com/blob/maste
r/turnip-expressions.md
* [10]http://cukes.info/turnip-expressions.html
I've taken a first-stab at implementing this for Cucumber-Ruby.
[11]https://github.com/cucumber/cucumber/pull/708
It follows the style that Jonas uses in Turnip.
Cucumber-Ruby already has $placeholders - which are quite
permissive. So I haven't changed that behaviour, and I don't
think we will remove that behaviour in Cucumber-Ruby 2.0 as
we're trying to minimize the number of _deliberate_ breaking
changes :)
I'm not sure we should have $placeholders for numbers and
:placeholders for strings, I think it would be better to use
custom placeholders[1].
WDYT?
[1]:
[12]https://github.com/jnicklas/turnip#custom-step-placeholders
Although it's not linked from anywhere on the [13]cukes.info
website yet it's a good starting point for us.
If we detect ambiguity, we could force the user to give hints,
for example an extra @Turnip annotation, or we could say that
// is a way to hint it's RegExp (slowly easing people toward
that convention).
WDYT?
Who wants to take a stab at implementing this? I think it's
simple enough that it can live alongside the cucumber codebase
- we don't need a separate lib.
Aslak
Post by aslak hellesoy[3] [14]https://github.com/jnicklas/turnip#placeholders
[4] [15]https://github.com/jnicklas/turnip/blob/master/lib/turn
ip/placeholder.rb
[5] [16]https://github.com/Behat/Behat/blob/master/src/Behat/Be
hat/Definition/Pattern/Policy/TurnipPatternPolicy.php
--
Posting rules: [17]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 [18]cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit [19]https://groups.google.com/d/optout.
--
Posting rules: [20]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 [21]cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit [22]https://groups.google.com/d/optout.
References
1. mailto:steve-***@public.gmane.org
2. http://tooky.co.uk/
3. http://kickstartacademy.io/
4. https://twitter.com/tooky
5. mailto:robert.d.park-***@public.gmane.org
6. mailto:aslak.hellesoy-***@public.gmane.org
7. mailto:paolo-***@public.gmane.org
8. mailto:aslak.hellesoy-***@public.gmane.org
9. https://github.com/cucumber/cucumber.github.com/blob/master/turnip-expressions.md
10. http://cukes.info/turnip-expressions.html
11. https://github.com/cucumber/cucumber/pull/708
12. https://github.com/jnicklas/turnip#custom-step-placeholders
13. http://cukes.info/
14. https://github.com/jnicklas/turnip#placeholders
15. https://github.com/jnicklas/turnip/blob/master/lib/turnip/placeholder.rb
16. https://github.com/Behat/Behat/blob/master/src/Behat/Behat/Definition/Pattern/Policy/TurnipPatternPolicy.php
17. http://cukes.info/posting-rules.html
18. mailto:cukes+unsubscribe-/***@public.gmane.org
19. https://groups.google.com/d/optout
20. http://cukes.info/posting-rules.html
21. mailto:cukes+unsubscribe-/***@public.gmane.org
22. 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.