rspec_rails_4 icon indicating copy to clipboard operation
rspec_rails_4 copied to clipboard

Ch.5, p.55 - Incomplete spec?

Open olerass opened this issue 12 years ago • 0 comments
trafficstars

This is more a question than an actual issue.

In the spec on page 55, does the saves the new contact in the database test really test that the new contact is saved?:

it "saves the new contact in the database" do
  expect{
  post :create, contact: attributes_for(:contact, phones_attributes: @phones)
  }.to change(Contact, :count).by(1)
end

In my opinion this test does nothing but test that some contact is saved (and thus should really be named saves some new contact in the database). The saved contact could be any valid contact, but there's nothing that checks the saved contact is actually the one submitted. Should we not test this?

Book version: 2013-10-29 (PDF)

olerass avatar Nov 02 '13 13:11 olerass