Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7508131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:37:35+00:00 2026-05-29T22:37:35+00:00

I am trying to pass the parameters from a .feature file (cucumber) to a

  • 0

I am trying to pass the parameters from a .feature file (cucumber) to a method call in a .rb file
heres what i have:
feature file

 When I set something to blah

step definition for the above feature file:

 When /^I set something to (.+)$/ do |value|
 methodcall(["#{value}"]))
 end

method in a separate .rb file

    def methodcall (a=[],b=[],c=[])
    a.each {|x| 
     do something with x
     }
        b.each {|y| 
     do something with y
     }
        c.each {|z| 
     do something with z
     }
     ...
    end

It works fine when I give only one parameter in .feature file . I am hoping that it’ll work for one value for each of the array (not tried this though)

but what I want to do is write in feature file something like this

       And I set something to "blah,blah1,blah2" and somethingelse to "blah4,blah5" and otherthings to "blah6, blah7"

for the above, step definition would look like

          When /^I set something to (.+) and somethingelse to (.+) and            
          and otherthings to (.+)$/ do |value, value1, value2|
          methodcall(["#{value}"], ["#{value1}"], ["#{value2}"]))
          end

and through the above step definition, have the values in value, value1, value2 to be passed in arguments corresponding to a=[], b=[], c=[] and call the methodcall() method. can someone please help.. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:37:35+00:00Added an answer on May 29, 2026 at 10:37 pm

    In your code

    methodcall(["#{value}"])
    

    You are taking the string value and turning it into the first element of an array, which is then passed to the methodcall().

    I believe what you actually want to do is

    methodcall(value.split(','))
    

    This will take your value, break it up by commas and puts each of those as an element of the array.

    To illustrate with your example, given that methodcall() is:

    def methodcall (a=[],b=[],c=[])
        a.each {|x| puts x }
        b.each {|y| puts y }
        c.each {|z| puts z }
    end
    

    Then

    value = "blah,blah1,blah2"
    methodcall(["#{value}"])
    #=> blah,blah1,blah2
    

    Where as

    value = "blah,blah1,blah2"
    methodcall(value.split(,))
    #=> blah
    #=> blah1
    #=> blah2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use an after_commit method to pass parameters from the post to
I am trying to pass parameters from Visual Studio using VB.net to a Crystal
I'm trying to pass parameters from a PHP middle tier to a java backend
I am trying to pass parameters from one action (foo) to another (foobar). In
I'm trying to pass some parameters (a couple of strings) from a page to
I'm trying to find an easy way to pass parameters from my C# class
trying to pass in data from a file as a cmd line argument in
I'm trying to pass 2 parameters from JQuery's Autocomplete plugin to an ASP.Net MVC2
I'm trying to pass parameters from HTML-land to Flex-3 Flash-land, and can't seem to
I'm trying to pass some parameters (count) from a form to a model. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.