This file contains hidden or 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
| FactoryBot.define do | |
| factory :article do | |
| title { Faker::Lorem.word } | |
| content { Faker::Lorem.paragraph(2) } | |
| end | |
| end |
This file contains hidden or 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
| class Article < ApplicationRecord | |
| validates_presence_of :title, :content | |
| end |
This file contains hidden or 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
| require 'rails_helper' | |
| RSpec.describe Article, type: :model do | |
| # Validation tests | |
| # ensure columns title and created_by are present before saving | |
| it { should validate_presence_of(:title) } | |
| it { should validate_presence_of(:content) } | |
| end |
This file contains hidden or 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
| # require database cleaner at the top level | |
| require 'database_cleaner' | |
| Shoulda::Matchers.configure do |config| | |
| config.integrate do |with| | |
| with.test_framework :rspec | |
| with.library :rails | |
| end | |
| end |
This file contains hidden or 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
| group :development, :test do | |
| gem 'rspec-rails' | |
| end | |
| group :test do | |
| gem 'factory_bot_rails' | |
| gem 'shoulda-matchers' | |
| gem 'faker' | |
| gem 'database_cleaner' | |
| end |
This file contains hidden or 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
| .... | |
| gem 'carrierwave' | |
| gem 'cloudinary' | |
| .... |
NewerOlder