Reputation: 1936
Let say I have the following step definition header for Ruby 2.3:
When (/^I update user group "([^"]*)" with (groups|users)?$/) do |group_name, type, params|
How do I use the "type" variable to distinguish between the case of using groups or users? What is the type of "type"?
Upvotes: 0
Views: 90
Reputation: 16224
in cucumber all the parameters are String, so you must to convert them with reflexion to the type you want.
When Cucumber matches a Step against a pattern in a Step Definition, it passes the value of all the capture groups to the Step Definition's arguments.
Capture groups are strings (even when they match digits like \d+). For statically typed languages, Cucumber will automatically transform those strings into the appropriate type. For dynamically typed languages, no transformation happens by default, as there is no type information.
reference https://cucumber.io/docs/reference
Upvotes: 1