Last active
December 26, 2015 01:09
-
-
Save ekhall/7069178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "PUT update" do | |
describe "with valid params" do | |
it "updates the requested article" do | |
article = Article.create! valid_attributes | |
Article.any_instance.should_receive(:update).with({ "these" => "params" }) | |
put :update, {:id => article.to_param, :article => { "these" => "params" }}, valid_session | |
end | |
it "assigns the requested article as @article" do | |
article = Article.create! valid_attributes | |
put :update, {:id => article.to_param, :article => valid_attributes}, valid_session | |
assigns(:article).should eq(article) | |
end | |
it "redirects to the article" do | |
article = Article.create! valid_attributes | |
put :update, {:id => article.to_param, :article => valid_attributes}, valid_session | |
response.should redirect_to(article) | |
end | |
end | |
... | |
it "re-renders the 'edit' template" do | |
article = Article.create! valid_attributes | |
# Trigger the behavior that occurs when invalid params are submitted | |
Article.any_instance.should_receive(:save).and_return(false) | |
put :update, {:id => article.to_param, :article => invalid_attributes }, valid_session | |
response.should render_template("edit") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ailures: | |
1) ArticlesController PUT update with valid params updates the requested article | |
Failure/Error: put :update, {:id => article.to_param, :article => { "these" => "params" }}, valid_session | |
#<Article:0x007fea0814ae70> received :update with unexpected arguments | |
expected: ({"these"=>"params"}) | |
got: ({}) | |
# ./app/controllers/articles_controller.rb:39:in `block in update' | |
# ./app/controllers/articles_controller.rb:38:in `update' | |
# ./spec/controllers/articles_controller_spec.rb:112:in `block (4 levels) in <top (required)>' | |
2) ArticlesController PUT update with valid params redirects to the article | |
Failure/Error: put :update, {:id => article.to_param, :article => valid_attributes}, valid_session | |
The message 'update' was received by #<Article id: 108, name: "MyArticleName", presentation_date: nil, journal: "MyJournal", publication_date: nil, presentation_comments: | |
nil, created_at: "2013-10-18 19:15:52", updated_at: "2013-10-18 19:15:52", user_id: nil> but has already been received by | |
# ./app/controllers/articles_controller.rb:39:in `block in update' | |
# ./app/controllers/articles_controller.rb:38:in `update' | |
# ./spec/controllers/articles_controller_spec.rb:123:in `block (4 levels) in <top (required)>' | |
3) ArticlesController PUT update with valid params assigns the requested article as @article | |
Failure/Error: put :update, {:id => article.to_param, :article => valid_attributes}, valid_session | |
The message 'update' was received by #<Article id: 109, name: "MyArticleName", presentation_date: nil, journal: "MyJournal", publication_date: nil, presentation_comments: | |
nil, created_at: "2013-10-18 19:15:52", updated_at: "2013-10-18 19:15:52", user_id: nil> but has already been received by | |
# ./app/controllers/articles_controller.rb:39:in `block in update' | |
# ./app/controllers/articles_controller.rb:38:in `update' | |
# ./spec/controllers/articles_controller_spec.rb:117:in `block (4 levels) in <top (required)>' | |
5) ArticlesController PUT update with invalid params re-renders the 'edit' template | |
Failure/Error: put :update, {:id => article.to_param, :article => invalid_attributes }, valid_session | |
The message 'update' was received by #<Article id: 111, name: "MyArticleName", presentation_date: nil, journal: "MyJournal", publication_date: nil, presentation_comments: nil, created_at: "2013-10-18 19:15:52", updated_at: "2013-10-18 19:15:52", user_id: nil> but has already been received by | |
# ./app/controllers/articles_controller.rb:39:in `block in update' | |
# ./app/controllers/articles_controller.rb:38:in `update' | |
# ./spec/controllers/articles_controller_spec.rb:141:in `block (4 levels) in <top (required)>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment