Reputation: 7043
How would you go with refactoring this piece of test-code using the 3.0 RSpec 'expect' syntax?
it "should destroy the micropost" do
lambda do
delete :destroy, :id => @micropost
flash[:success].should =~ /deleted/i
response.should redirect_to(root_path)
end.should change(Micropost, :count).by(-1)
end
Upvotes: 0
Views: 43
Reputation: 37409
it "destroys the micropost" do
expect {
delete :destroy, :id => @micropost
expect(flash[:success]).to match /deleted/i
expect(response).to redirect_to(root_path)
}.to change(Micropost, :count).by(-1)
end
sources: redirect_to
, match
and change
Upvotes: 2