New style mocking
This commit is contained in:
@@ -84,7 +84,7 @@ describe Cmtool::ContactFormsController, type: :controller do
|
|||||||
# specifies that the Cmtool::ContactForm created on the previous line
|
# specifies that the Cmtool::ContactForm created on the previous line
|
||||||
# receives the :update_attributes message with whatever params are
|
# receives the :update_attributes message with whatever params are
|
||||||
# submitted in the request.
|
# submitted in the request.
|
||||||
Cmtool::ContactForm.any_instance.should_receive(:update_attributes).with({'name' => 'Zeikurt'})
|
expect_any_instance_of( Cmtool::ContactForm ).to receive(:update_attributes).with({'name' => 'Zeikurt'})
|
||||||
put :update, :id => contact_form.id, :contact_form => {'name' => 'Zeikurt'}
|
put :update, :id => contact_form.id, :contact_form => {'name' => 'Zeikurt'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ describe Cmtool::FaqsController, type: :controller do
|
|||||||
# specifies that the Cmtool::Faq created on the previous line
|
# specifies that the Cmtool::Faq created on the previous line
|
||||||
# receives the :update_attributes message with whatever params are
|
# receives the :update_attributes message with whatever params are
|
||||||
# submitted in the request.
|
# submitted in the request.
|
||||||
Cmtool::Faq.any_instance.should_receive(:update_attributes).with({'question' => 'meaning of life'})
|
expect_any_instance_of( Cmtool::Faq ).to receive(:update_attributes).with({'question' => 'meaning of life'})
|
||||||
put :update, :id => faq.id, :faq => {'question' => 'meaning of life'}
|
put :update, :id => faq.id, :faq => {'question' => 'meaning of life'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -78,14 +78,14 @@ describe Cmtool::NewsletterSubscriptionsController, type: :controller do
|
|||||||
describe "with invalid params" do
|
describe "with invalid params" do
|
||||||
it "assigns a newly created but unsaved newsletter_subscription as @newsletter_subscription" do
|
it "assigns a newly created but unsaved newsletter_subscription as @newsletter_subscription" do
|
||||||
# Trigger the behavior that occurs when invalid params are submitted
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
Cmtool::NewsletterSubscription.any_instance.stub(:save).and_return(false)
|
allow_any_instance_of( Cmtool::NewsletterSubscription ).to receive(:save).and_return(false)
|
||||||
post :create, :newsletter_subscription => {email: ''}
|
post :create, :newsletter_subscription => {email: ''}
|
||||||
assigns(:newsletter_subscription).should be_a_new(Cmtool::NewsletterSubscription)
|
assigns(:newsletter_subscription).should be_a_new(Cmtool::NewsletterSubscription)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'new' template" do
|
it "re-renders the 'new' template" do
|
||||||
# Trigger the behavior that occurs when invalid params are submitted
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
Cmtool::NewsletterSubscription.any_instance.stub(:save).and_return(false)
|
allow_any_instance_of( Cmtool::NewsletterSubscription ).to receive(:save).and_return(false)
|
||||||
post :create, :newsletter_subscription => {email: ''}
|
post :create, :newsletter_subscription => {email: ''}
|
||||||
response.should render_template("new")
|
response.should render_template("new")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user