Skip to content

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

@sameera207

Description

@sameera207

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions