ruby on rails - Rspec controller testing for update of article does not work -



ruby on rails - Rspec controller testing for update of article does not work -

here controller_spec file portion of relevant code.....

login_user context 'update article valid attributes' 'update article'do article = article.create!(attributes_for(:article)) set :update, id:article.to_param, :article => attributes_for(:article, title: "title changed") article.reload expect(article.first.title).to eq("title changed") end end end

i getting error failure/error: expect(article.first.title).to eq("title changed")

expected: "title changed" got: "my first post" (compared using ==)

the controller code of update

# ..articlescontroller#update def update @article = article.find(params[:id]) if @article.update(article_params) redirect_to @article else render 'edit' end end

ruby-on-rails rspec

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -