Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails, rspec, post array like "hey[]=1"

I need to test if client includes POINTS array in post-request. When I test it with RESTClient plugin for firefox, I do it like this:

POINTS[]=1.111111,2.222222,77

and it works. Now I need to test it via rspec, but I can't figure out how to do it. Here is my rspec test request:

post :event, DISTANCE: "12345", POINTS: { "1" => "1.111111,2.222222,77" }

But somehow it does not work. puts p.inspect shows: ["1", "1.111111,2.222222,77"] and it's not what I want.

Thanks.

like image 567
Alexander Avatar asked Mar 23 '26 02:03

Alexander


1 Answers

As already told in comments, do:

post :event, distance: "12345", points:  ["1.111111,2.222222,77"]
like image 188
apneadiving Avatar answered Mar 25 '26 17:03

apneadiving



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!