Ruby on rails 在测试中,如何将默认请求参数传递给get/post/put/delete

Ruby on rails 在测试中,如何将默认请求参数传递给get/post/put/delete,ruby-on-rails,ruby,rspec,Ruby On Rails,Ruby,Rspec,考虑这个例子: describe UsersController do it "works for something" do # some other code get :show, {facebook_id: 1000000000} # some other code put :update, {facebook_id: 1000000000, birthday: "2001-01-01"} # some other code get :s

考虑这个例子:

describe UsersController do
  it "works for something" do
    # some other code
    get :show, {facebook_id: 1000000000}
    # some other code
    put :update, {facebook_id: 1000000000, birthday: "2001-01-01"}
    # some other code
    get :show, {facebook_id: 1000000000}
    # some other code
  end

  it "works for another thing" do
    # some other code
    get :show, {facebook_id: 1000000000}
    # some other code
  end
end
如何将
{facebook\u id:1000000000}
晾干,这样我就可以简单地写
get:show
put:update,{生日:“2001-01-01”}
,等等?

怎么样

def options(*args)
  _options = args.extract_options!
  _options.merge({facebook_id: 1000000000})
end
然后


你的控制器如何处理facebook的id?我会在你不测试facebook_id的时候,截取这个方法,就像我在这里建议的那样

get :show, options
put :update, options(birthday: "2001-01-01")