Discussion:
[Cucumber] [Ruby] is there possibility to run in parallel ParameterType regex and pure step regex?
s***@gmail.com
2018-06-01 13:43:09 UTC
Permalink
Hi guys!

So, I have, i.e. next two steps:
And('Custom ParameterType {pt_test}') do |pt_test|

end

And(/^Another custom ParameterType (.+)$/) do |pt_test|

end

and next ParameterType:
ParameterType(
name: 'pt_test',
regexp: /.+/,
type: String,
transformer: -> (str) { require 'pry'; binding.pry; str }
)

The steps above uses the same regex, so can I somehow split this steps, so
first can be wrapped by ParameterType and second not?

Thank you for help,
Serhii
--
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-06-01 14:12:36 UTC
Permalink
See answers inline
Post by s***@gmail.com
Hi guys!
And('Custom ParameterType {pt_test}') do |pt_test|
end
And(/^Another custom ParameterType (.+)$/) do |pt_test|
end
ParameterType(
name: 'pt_test',
regexp: /.+/,
type: String,
transformer: -> (str) { require 'pry'; binding.pry; str }
)
The steps above uses the same regex, so can I somehow split this steps, so
first can be wrapped by ParameterType and second not?
When you define a parameter type, that parameter type's regexp will be used
in all matches, whether they are from Cucumber Expressions (as your first
stepdef) or a Regular Expression (as your second one).

If you want regexp matches to use a *different* parameter type, you can
define another parameter type with the same regexp, and pass in the option
prefer_for_regexp_match: true. (The value defaults to false if you don't
specify it).

If you don't plan to use this parameter type from a Cucumber Expression,
just give it an arbitrary name. (A future release might allow you to omit
the name altogether).

Hope this helps,
Aslak
Post by s***@gmail.com
Thank you for help,
Serhii
--
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.
s***@gmail.com
2018-06-01 14:25:36 UTC
Permalink
Yes, this works, thanks for your help!

Regards,
Serhii
--
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...