reinteractive-open / installfest_guides

The installfest guides
24 stars 29 forks source link

Update the guide to use `shoulda-matchers` gem for the model validations. #238

Open sameera207 opened 5 years ago

sameera207 commented 5 years ago

Using shoulda-matchers for model validations will be easier to understand over the current example.

it { should validate_presence_of(:title) }

instead of

[:title, :body].each do |attribute|
  it "should validate presence of #{attribute}" do
    expect(post.errors[attribute].size).to be >= 1
    expect(post.errors.messages[attribute]).to include "can't be blank"
  end
end