- GitHub Staff
- susanwere.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'rails_helper' | |
RSpec.describe Product, type: :model do | |
before do | |
@invalid_product = Product.new(title: '', description: '', price: '') | |
@valid_product = Product.new(title: 'One', description: 'description one', price: '100.00') | |
@invalid_price = Product.new(title: 'One', description: 'description one', price: '0.00') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before do | |
@invalid_product = Product.new(title: '', description: '', price: '') | |
@valid_product = Product.new(title: 'One', description: 'description one', price: '100.00') | |
@invalid_price = Product.new(title: 'One', description: 'description one', price: '0.00') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
from authors.apps.authentication.models.UserManager import create_user | |
class UserTestCase(TestCase): | |
def test_to_create_user(self): | |
"""user can be registered""" | |
create_user.user = (username="patty", email="patty@gmail.com", password="patty123") | |
new_user = create_user.user | |
self.assertEqual(new_user.username, "patty") | |
self.assertEqual(new_user.email, "patty@gmail.com") |