1

以下は、IDとトークンmodelを受け入れる私の方法です。auth

Project.find( id: '22', authorization: auth)

以下は私のテストです。

require 'project'

RSpec.describe Project do
  it 'finds an project' do
    project = class_double("project")    
    expect(project).to receive(:find).with() 
                             // How can i send id and authorization inside with       
  end
end

this test pass?を渡しidauthorization内部で作成するにはどうすればよいwithですか。

4

1 に答える 1

0

Project.find(id: '22', authorization: auth)は次の省略形です。 Project.find({id: '22', authorization: auth})

これは、'find' に 1 つのパラメーター、つまりハッシュを渡していることを意味します。

expect(project).to receive(:find).with({id: the_id, authorization: the_auth})

必要に応じて中括弧を省略できます。

于 2014-08-12T00:27:55.157 に答える