ruby on rails - Passing Two Parameters on a JSON POST Request in Rspec -


i have json rails 4 api i'm testing rspec. i'm having trouble passing 2 parameters in post :create request.

here current test:

 require 'spec_helper'   module api     module v1       describe api::v1::productscontroller, type: :controller          before           @api_app = factorygirl.create(:api_app, request_origin: "0.0.0.0")           @store = factorygirl.create(:store)         end          after(:all)           product.all.each {|l| l.destroy}           apiapp.all.each {|a| a.destroy}         end          describe "post 'create' "           context "creates product correct parameters"             "returns successful response string success message"               json = { :format => 'json', product:{first_name:"hello", last_name:"you", email:"email@email.edu",street1:"103 abc street", city:"pittsburgh", phone:"4125361111", store_id:@store.id, state:"ca", country:"united states", organization:"abc", organization_type: "org"}}               post :create, json, access_token: @api_app.access_token                expect(response).to be_success               expect(response.body).to include("product created")             end           end            context "incorrect parameters create product"             "returns failure response when parameter missing"               json = { :format => 'json', product:{first_name:"hello", last_name:"you", email:"email@email.edu",street1:"103 abc street", city:"pittsburgh", phone:"4125361111", store_id:@store.id, state:"ca", country:"united states", organization:"abc"}}               post :create, json, access_token: @api_app.access_token                expect(response).to be_success               expect(response.body).to include("product failed create")             end           end         end       end     end   end 

i need both json , access_token on line:

post :create, json, access_token: @api_app.access_token 

but request ignores second parameter (i can switch placement confirm). how word post both parameters read in?

i think should send single hash in post. try following:

post :create, json.merge!(access_token: @api_app.access_token) 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -