Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass Array value in cucumber .feature file

I want to pass array value as a parameter from cucumber .feature file, so I can access it from step definition file:

I am using this format:

Examples:
|r1|t1|
|abc|[aa,bb,cc]| 

But I'm getting an error undefined methodeach' for "[aa,bb,cc]":String (NoMethodError)`

Is it possible to pass array from .feature file?

like image 584
Shobhit Gupta Avatar asked Jun 14 '16 19:06

Shobhit Gupta


1 Answers

I don't think you need the square brackets.

When I pass this array "aa,bb,cc"

You have to split your string up.

When(/I pass this array "([^"]*)"$/) do |array|
  array.split(',').each{|entry| do something }
end

Note: you may want to strip the entries in case there is whitespace around them {|entry| puts entry.strip }

like image 72
Dave McNulla Avatar answered Oct 08 '22 13:10

Dave McNulla