I'm trying to mock some requests which have dynamic parameters and they constantly change each time I ran the tests!
Is there any way I could set parameters with variables?
for Get method you can set template but nothing for Post!
body = {
"id":"#{user_id}",
"type":["User","ActiveRecord::Base"],
"class_name":"User",
"email_text":"user@example.com",
}.to_json
stub_request(:post, "http://solr/test/update?wt=json").
with(
body: "[#{body}]",
headers: {
'Accept'=>'*/*',
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Content-Type'=>'application/json',
}).to_return(status: 200, body: "", headers: {})
any user_id should be acceptable