Railsのテスト
RailsはRSpecを使用して、テストを自動化します。
RSpecのインストール
Section titled “RSpecのインストール”gem install rspec
テストの作成
Section titled “テストの作成”require 'rails_helper'
RSpec.describe Book, type: :model do it 'is valid with valid attributes' do book = Book.new(title: 'Sample Book', author: 'Author Name') expect(book).to be_valid endend
RSpec.describe
: テスト対象を指定expect
: 期待する結果を定義