Skip to content

Instantly share code, notes, and snippets.

@susanwere
Created April 16, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susanwere/5cd82145dae9ec1fef6ca018b0e163df to your computer and use it in GitHub Desktop.
Save susanwere/5cd82145dae9ec1fef6ca018b0e163df to your computer and use it in GitHub Desktop.
model test for title
describe 'title' do
it 'validates presence of title' do
product = @invalid_product
product.valid?
expect(product.errors[:title]).to include("can't be blank")
end
it 'validates uniqueness of a title' do
@valid_product.save
new_product = @valid_product.dup
new_product.valid?
expect(new_product.errors[:title]).to include('has already been taken')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment