Search code examples
ruby-on-railsrspecrspec-rails

put_via_redirect need quick example


i want an example of put_via_redirect my code

 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 not found error enter image description here


Solution

  • Your authors table is empty. Try populating a sample record before checking the response.

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