put_via_redirect需要快速举例

时间:2014-11-09 12:16:35

标签: ruby-on-rails rspec rspec-rails

我想要一个put_via_redirect的例子 我的代码

 describe "PUT /authors/1" do
    it "will update author with id 1" do

    put_via_redirect( author_path(Author.find(1)), {:author => { name: "tim"}} )
    expect(response.body).to include("Tim")

    end
    # ....
 end

找不到Active_record错误 enter image description here

1 个答案:

答案 0 :(得分:1)

您的authors表格为空。尝试在检查响应之前填充样本记录。

Author.create(id: 1, name: 'Tim')