Open wassupdee opened 6 days ago
以下に箇条書きで記載しました🙇 letではなくlet!を使っても同様のエラーが出てしまうかを試してみてください。
- 仮説は正しいですが、より具体的な原因はletの遅延評価やトランザクションフィクスチャとFiberの競合である可能性が高いです。
- letの遅延評価による問題
- letは遅延評価されるため、テスト内でのデータベース接続のタイミングがFiberと競合する可能性があります。
- 対策案:letではなくlet!を使用して、事前にデータを作成します。
どうもありがとうございます!
question_spec.rb含め、spec/modelディレクトリ内のすべてのlet --> let!に変更しました。
spec/models/question_spec.rb
require "rails_helper"
RSpec.describe Question, type: :model do
let!(:question) { create(:question) }
let!(:answer1) { create(:answer, question:) }
let!(:answer2) { create(:answer, question:) }
describe "アソシエーションチェック" do
it "answersと1対多の関係にある" do
expect(question.answers).to include(answer1, answer2)
end
it "関連するanswersがあっても、questionを削除でき、answersも削除される" do
expect { question.destroy }.to change { Question.count }.by(-1)
expect(Answer.where(id: [answer1.id, answer2.id])).to be_empty
end
end
end
エラーの解消には至りませんでした。同じエラーが発生してしまいます。
Question アソシエーションチェック answersと1対多の関係にある
Failure/Error: _query(sql, @query_options.merge(options))
ActiveRecord::StatementInvalid:
Mysql2::Error: This connection is in use by: #<Fiber:0x00007ff1dc4018b8 (resumed)>
# /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `_query'
# /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `block in query'
# /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `handle_interrupt'
# /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:150:in `query'
# ------------------
# --- Caused by: ---
# Mysql2::Error:
# This connection is in use by: #<Fiber:0x00007ff1dc4018b8 (resumed)>
# /usr/local/bundle/gems/mysql2-0.5.6/lib/mysql2/client.rb:151:in `_query'
トランズアクションフィックスチャの影響かと考え、spec/rails_helper.rb
にて、
config.use_transactional_fixtures = true
--> config.use_transactional_fixtures = false
に変更してみました。
# This file is copied to spec/ when you run "rails generate rspec:install"
require "spec_helper"
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require "rspec/rails"
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
Dir[Rails.root.join("spec", "support", "**", "*.rb")].each { |f| require f }
# Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }
# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
abort e.to_s.strip
end
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_paths = [
Rails.root.join("spec/fixtures")
]
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, type: :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://rspec.info/features/6-0/rspec-rails
config.infer_spec_type_from_file_location!
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
config.include FactoryBot::Syntax::Methods
config.before(:each, type: :system) do
driven_by :selenium_chrome_headless
end
end
Fiberとの競合エラーはなくなりましたが、 テストDBのRollbackが行われないため、 テスト用のレコードがDBに残り重複エラーが発生しました。
$ dc exec web bundle exec rspec spec/models
Album
アソシエーションチェック
profileとのアソシエーション
profileと1対多の関係にある (FAILED - 1)
バリデーションチェック
無効なデータの場合
無効なファイル形式はアップロードできない (FAILED - 2)
5MB以上のファイルはアップロードできない (FAILED - 3)
画像は4枚以上アップロードできない (FAILED - 4)
有効なデータの場合
正常に画像が保存される (FAILED - 5)
Answer
アソシエーションチェック
questionとのアソシエーション
questionと1対多の関係にある (FAILED - 6)
バリデーションチェック
valueがユニークであれば登録できる (FAILED - 7)
valueが重複するとエラーが起きる (FAILED - 8)
ロジックチェック
セッションに各問の回答を保存する (FAILED - 9)
パラメーターから現在の質問番号を取得する (FAILED - 10)
現在の質問が最後か確認する (FAILED - 11)
Authentication
アソシエーションチェック
userとのアソシエーション
userと1対多の関係にある (FAILED - 12)
Event
アソシエーションチェック
profileとのアソシエーション
profileと1対多の関係にある (FAILED - 13)
ロジックチェック
通知の条件を満たしているか確認する (FAILED - 14)
日付をUTCからJSTへ変換する(9時間先に進める) (FAILED - 15)
特定の日付の「年」を今年に変更する (FAILED - 16)
通知日は今日か確認する (FAILED - 17)
バリデーションチェック
1profileあたりの登録できるイベント数を2つまでに制限する (FAILED - 18)
enumチェック
boolean型のnotification_enabledが、off/onに対応している (FAILED - 19)
Profile
アソシエーションチェック
userとのアソシエーション
userと1対多の関係にある (FAILED - 20)
albumsとのアソシエーション
albumsと1対多の関係にある (FAILED - 21)
関連するalbumsがあっても、profileを削除でき、albumsも削除される (FAILED - 22)
eventsとのアソシエーション
eventsと1対多の関係にある (FAILED - 23)
関連するeventsがあっても、profileを削除でき、eventsも削除される (FAILED - 24)
accepts_nested_attributes_for
profileモデルが更新される際、ネストされたeventsの属性も保存する (FAILED - 25)
ロジックチェック
誕生日のチェック
誕生日の月が今月か判定する(同月の場合) (FAILED - 26)
誕生日の月が今月か判定する(違う月の場合) (FAILED - 27)
大切な日のチェック
大切な日の月が今月か判定する(同月の場合) (FAILED - 28)
大切な日の月が今月か判定する(同月の場合) (FAILED - 29)
ransack
検索のための属性を定義する (FAILED - 30)
enumチェック
last_contactedにenumが付いている (FAILED - 31)
バリデーションチェック
無効なデータの場合
無効なファイル形式はアップロードできない (FAILED - 32)
1MB以上のファイルはアップロードできない (FAILED - 33)
有効なデータの場合
正常に画像が保存される (FAILED - 34)
Question
アソシエーションチェック
answersと1対多の関係にある (FAILED - 35)
関連するanswersがあっても、questionを削除でき、answersも削除される (FAILED - 36)
User
バリデーション
名前、メール、パスワード、確認用パスワード、notification_enabledがある場合、有効である
名前がない場合、無効である (FAILED - 37)
名前が255文字以上場合、無効である (FAILED - 38)
メールアドレスがない場合、無効である (FAILED - 39)
重複したメールアドレスの場合、無効である (FAILED - 40)
パスワードが2文字以下の場合、無効である (FAILED - 41)
パスワード(確認用)がない場合、無効である (FAILED - 42)
パスワード(確認用)がパスワードと一致しない場合、無効である (FAILED - 43)
notificaiton_enabledない場合、無効である (FAILED - 44)
line_user_idがblankの場合、重複していても有効である (FAILED - 45)
notification_enabledがenumで定義されている (FAILED - 46)
アソシエーションチェック
profilesとのアソシエーション
profilesと1対多の関係にある (FAILED - 47)
関連するprofilesがあっても、userを削除でき、profilesも削除される (FAILED - 48)
groupsとのアソシエーション
groupsと1対多の関係にある (FAILED - 49)
関連するgroupsがあっても、userを削除でき、groupsも削除される (FAILED - 50)
authenticationsとのアソシエーション
authenticationsと1対多の関係にある (FAILED - 51)
関連するauthenticationsがあっても、userを削除でき、authenticationsも削除される (FAILED - 52)
eventsとのアソシエーション
eventsと1対多の関係にある (FAILED - 53)
関連するeventsがあっても、userを削除でき、eventsも削除される (FAILED - 54)
accepts_nested_attributes_for
userモデルが更新される際、ネストされたauthenticationsの属性も保存する (FAILED - 55)
メソッドのテスト
LINE通知の対象ユーザーを取得する (FAILED - 56)
Failures:
1) Album アソシエーションチェック profileとのアソシエーション profileと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/album_spec.rb:4:in `block (2 levels) in <top (required)>'
2) Album バリデーションチェック 無効なデータの場合 無効なファイル形式はアップロードできない
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/album_spec.rb:4:in `block (2 levels) in <top (required)>'
3) Album バリデーションチェック 無効なデータの場合 5MB以上のファイルはアップロードできない
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/album_spec.rb:4:in `block (2 levels) in <top (required)>'
4) Album バリデーションチェック 無効なデータの場合 画像は4枚以上アップロードできない
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/album_spec.rb:4:in `block (2 levels) in <top (required)>'
5) Album バリデーションチェック 有効なデータの場合 正常に画像が保存される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/album_spec.rb:4:in `block (2 levels) in <top (required)>'
6) Answer アソシエーションチェック questionとのアソシエーション questionと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/answer_spec.rb:4:in `block (2 levels) in <main>'
7) Answer バリデーションチェック valueがユニークであれば登録できる
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/answer_spec.rb:4:in `block (2 levels) in <main>'
8) Answer バリデーションチェック valueが重複するとエラーが起きる
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/answer_spec.rb:4:in `block (2 levels) in <main>'
9) Answer ロジックチェック セッションに各問の回答を保存する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/answer_spec.rb:4:in `block (2 levels) in <main>'
10) Answer ロジックチェック パラメーターから現在の質問番号を取得する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/answer_spec.rb:4:in `block (2 levels) in <main>'
11) Answer ロジックチェック 現在の質問が最後か確認する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/answer_spec.rb:4:in `block (2 levels) in <main>'
12) Authentication アソシエーションチェック userとのアソシエーション userと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/authentication_spec.rb:4:in `block (2 levels) in <main>'
13) Event アソシエーションチェック profileとのアソシエーション profileと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:4:in `block (2 levels) in <main>'
14) Event ロジックチェック 通知の条件を満たしているか確認する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:4:in `block (2 levels) in <main>'
15) Event ロジックチェック 日付をUTCからJSTへ変換する(9時間先に進める)
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:4:in `block (2 levels) in <main>'
16) Event ロジックチェック 特定の日付の「年」を今年に変更する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:4:in `block (2 levels) in <main>'
17) Event ロジックチェック 通知日は今日か確認する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:4:in `block (2 levels) in <main>'
18) Event バリデーションチェック 1profileあたりの登録できるイベント数を2つまでに制限する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:4:in `block (2 levels) in <main>'
19) Event enumチェック boolean型のnotification_enabledが、off/onに対応している
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/event_spec.rb:4:in `block (2 levels) in <main>'
20) Profile アソシエーションチェック userとのアソシエーション userと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
21) Profile アソシエーションチェック albumsとのアソシエーション albumsと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
22) Profile アソシエーションチェック albumsとのアソシエーション 関連するalbumsがあっても、profileを削除でき、albumsも削除される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
23) Profile アソシエーションチェック eventsとのアソシエーション eventsと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
24) Profile アソシエーションチェック eventsとのアソシエーション 関連するeventsがあっても、profileを削除でき、eventsも削除される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
25) Profile accepts_nested_attributes_for profileモデルが更新される際、ネストされたeventsの属性も保存する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
26) Profile ロジックチェック 誕生日のチェック 誕生日の月が今月か判定する(同月の場合)
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
27) Profile ロジックチェック 誕生日のチェック 誕生日の月が今月か判定する(違う月の場合)
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
28) Profile ロジックチェック 大切な日のチェック 大切な日の月が今月か判定する(同月の場合)
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
29) Profile ロジックチェック 大切な日のチェック 大切な日の月が今月か判定する(同月の場合)
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
30) Profile ロジックチェック ransack 検索のための属性を定義する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
31) Profile enumチェック last_contactedにenumが付いている
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
32) Profile バリデーションチェック 無効なデータの場合 無効なファイル形式はアップロードできない
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
33) Profile バリデーションチェック 無効なデータの場合 1MB以上のファイルはアップロードできない
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
34) Profile バリデーションチェック 有効なデータの場合 正常に画像が保存される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/profile_spec.rb:4:in `block (2 levels) in <main>'
35) Question アソシエーションチェック answersと1対多の関係にある
Failure/Error: let!(:answer1) { create(:answer, question:) }
ActiveRecord::RecordInvalid:
Validation failed: Value has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/question_spec.rb:5:in `block (2 levels) in <main>'
36) Question アソシエーションチェック 関連するanswersがあっても、questionを削除でき、answersも削除される
Failure/Error: let!(:answer1) { create(:answer, question:) }
ActiveRecord::RecordInvalid:
Validation failed: Value has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/question_spec.rb:5:in `block (2 levels) in <main>'
37) User バリデーション 名前がない場合、無効である
Failure/Error: expect(user.errors[:name]).to include("名前を入力してください")
expected ["can't be blank"] to include "名前を入力してください"
# ./spec/models/user_spec.rb:13:in `block (3 levels) in <main>'
38) User バリデーション 名前が255文字以上場合、無効である
Failure/Error: expect(user.errors[:name]).to include("255文字以内で入力してください")
expected ["is too long (maximum is 255 characters)"] to include "255文字以内で入力してください"
# ./spec/models/user_spec.rb:19:in `block (3 levels) in <main>'
39) User バリデーション メールアドレスがない場合、無効である
Failure/Error: expect(user.errors[:email]).to include("メールアドレスを入力してください")
expected ["can't be blank"] to include "メールアドレスを入力してください"
# ./spec/models/user_spec.rb:25:in `block (3 levels) in <main>'
40) User バリデーション 重複したメールアドレスの場合、無効である
Failure/Error: other_user = create(:user)
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:29:in `block (3 levels) in <main>'
41) User バリデーション パスワードが2文字以下の場合、無効である
Failure/Error: expect(user.errors[:password]).to include("パスワードは3文字以上で設定してください")
expected ["is too short (minimum is 3 characters)"] to include "パスワードは3文字以上で設定してください"
# ./spec/models/user_spec.rb:38:in `block (3 levels) in <main>'
42) User バリデーション パスワード(確認用)がない場合、無効である
Failure/Error: expect(user.errors[:password_confirmation]).to include("確認用のパスワードを入力してください")
expected ["doesn't match Password", "can't be blank"] to include "確認用のパスワードを入力してください"
# ./spec/models/user_spec.rb:44:in `block (3 levels) in <main>'
43) User バリデーション パスワード(確認用)がパスワードと一致しない場合、無効である
Failure/Error: expect(user.errors[:password_confirmation]).to include("パスワードと一致しません")
expected ["doesn't match Password"] to include "パスワードと一致しません"
# ./spec/models/user_spec.rb:50:in `block (3 levels) in <main>'
44) User バリデーション notificaiton_enabledない場合、無効である
Failure/Error: expect(user.errors[:notification_enabled]).to include("通知を設定してください")
expected ["can't be blank"] to include "通知を設定してください"
# ./spec/models/user_spec.rb:56:in `block (3 levels) in <main>'
45) User バリデーション line_user_idがblankの場合、重複していても有効である
Failure/Error: create(:user, line_user_id: "")
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:60:in `block (3 levels) in <main>'
46) User バリデーション notification_enabledがenumで定義されている
Failure/Error: user1 = create(:user, notification_enabled: true)
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:67:in `block (3 levels) in <main>'
47) User アソシエーションチェック profilesとのアソシエーション profilesと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
48) User アソシエーションチェック profilesとのアソシエーション 関連するprofilesがあっても、userを削除でき、profilesも削除される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
49) User アソシエーションチェック groupsとのアソシエーション groupsと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
50) User アソシエーションチェック groupsとのアソシエーション 関連するgroupsがあっても、userを削除でき、groupsも削除される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
51) User アソシエーションチェック authenticationsとのアソシエーション authenticationsと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
52) User アソシエーションチェック authenticationsとのアソシエーション 関連するauthenticationsがあっても、userを削除でき、authenticationsも削除される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
53) User アソシエーションチェック eventsとのアソシエーション eventsと1対多の関係にある
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
54) User アソシエーションチェック eventsとのアソシエーション 関連するeventsがあっても、userを削除でき、eventsも削除される
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:75:in `block (3 levels) in <main>'
55) User accepts_nested_attributes_for userモデルが更新される際、ネストされたauthenticationsの属性も保存する
Failure/Error: let!(:user) { create(:user) }
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:136:in `block (3 levels) in <main>'
56) User メソッドのテスト LINE通知の対象ユーザーを取得する
Failure/Error: user_to_notify = create(:user, line_user_id: "aaa", notification_enabled: true)
ActiveRecord::RecordInvalid:
Validation failed: Email has already been taken
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/evaluation.rb:15:in `create'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy/create.rb:9:in `result'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory.rb:43:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/factory_runner.rb:28:in `run'
# /usr/local/bundle/gems/factory_bot-6.4.6/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
# ./spec/models/user_spec.rb:155:in `block (3 levels) in <main>'
Finished in 1.03 seconds (files took 3.96 seconds to load)
57 examples, 56 failures
Failed examples:
rspec ./spec/models/album_spec.rb:13 # Album アソシエーションチェック profileとのアソシエーション profileと1対多の関係にある
rspec ./spec/models/album_spec.rb:21 # Album バリデーションチェック 無効なデータの場合 無効なファイル形式はアップロードできない
rspec ./spec/models/album_spec.rb:25 # Album バリデーションチェック 無効なデータの場合 5MB以上のファイルはアップロードできない
rspec ./spec/models/album_spec.rb:29 # Album バリデーションチェック 無効なデータの場合 画像は4枚以上アップロードできない
rspec ./spec/models/album_spec.rb:36 # Album バリデーションチェック 有効なデータの場合 正常に画像が保存される
rspec ./spec/models/answer_spec.rb:10 # Answer アソシエーションチェック questionとのアソシエーション questionと1対多の関係にある
rspec ./spec/models/answer_spec.rb:17 # Answer バリデーションチェック valueがユニークであれば登録できる
rspec ./spec/models/answer_spec.rb:24 # Answer バリデーションチェック valueが重複するとエラーが起きる
rspec ./spec/models/answer_spec.rb:33 # Answer ロジックチェック セッションに各問の回答を保存する
rspec ./spec/models/answer_spec.rb:41 # Answer ロジックチェック パラメーターから現在の質問番号を取得する
rspec ./spec/models/answer_spec.rb:48 # Answer ロジックチェック 現在の質問が最後か確認する
rspec ./spec/models/authentication_spec.rb:9 # Authentication アソシエーションチェック userとのアソシエーション userと1対多の関係にある
rspec ./spec/models/event_spec.rb:10 # Event アソシエーションチェック profileとのアソシエーション profileと1対多の関係にある
rspec ./spec/models/event_spec.rb:17 # Event ロジックチェック 通知の条件を満たしているか確認する
rspec ./spec/models/event_spec.rb:21 # Event ロジックチェック 日付をUTCからJSTへ変換する(9時間先に進める)
rspec ./spec/models/event_spec.rb:29 # Event ロジックチェック 特定の日付の「年」を今年に変更する
rspec ./spec/models/event_spec.rb:37 # Event ロジックチェック 通知日は今日か確認する
rspec ./spec/models/event_spec.rb:57 # Event バリデーションチェック 1profileあたりの登録できるイベント数を2つまでに制限する
rspec ./spec/models/event_spec.rb:69 # Event enumチェック boolean型のnotification_enabledが、off/onに対応している
rspec ./spec/models/profile_spec.rb:12 # Profile アソシエーションチェック userとのアソシエーション userと1対多の関係にある
rspec ./spec/models/profile_spec.rb:21 # Profile アソシエーションチェック albumsとのアソシエーション albumsと1対多の関係にある
rspec ./spec/models/profile_spec.rb:25 # Profile アソシエーションチェック albumsとのアソシエーション 関連するalbumsがあっても、profileを削除でき、albumsも削除される
rspec ./spec/models/profile_spec.rb:35 # Profile アソシエーションチェック eventsとのアソシエーション eventsと1対多の関係にある
rspec ./spec/models/profile_spec.rb:39 # Profile アソシエーションチェック eventsとのアソシエーション 関連するeventsがあっても、profileを削除でき、eventsも削除される
rspec ./spec/models/profile_spec.rb:74 # Profile accepts_nested_attributes_for profileモデルが更新される際、ネストされたeventsの属性も保存する
rspec ./spec/models/profile_spec.rb:95 # Profile ロジックチェック 誕生日のチェック 誕生日の月が今月か判定する(同月の場合)
rspec ./spec/models/profile_spec.rb:100 # Profile ロジックチェック 誕生日のチェック 誕生日の月が今月か判定する(違う月の場合)
rspec ./spec/models/profile_spec.rb:107 # Profile ロジックチェック 大切な日のチェック 大切な日の月が今月か判定する(同月の場合)
rspec ./spec/models/profile_spec.rb:114 # Profile ロジックチェック 大切な日のチェック 大切な日の月が今月か判定する(同月の場合)
rspec ./spec/models/profile_spec.rb:123 # Profile ロジックチェック ransack 検索のための属性を定義する
rspec ./spec/models/profile_spec.rb:130 # Profile enumチェック last_contactedにenumが付いている
rspec ./spec/models/profile_spec.rb:137 # Profile バリデーションチェック 無効なデータの場合 無効なファイル形式はアップロードできない
rspec ./spec/models/profile_spec.rb:141 # Profile バリデーションチェック 無効なデータの場合 1MB以上のファイルはアップロードできない
rspec ./spec/models/profile_spec.rb:148 # Profile バリデーションチェック 有効なデータの場合 正常に画像が保存される
rspec ./spec/models/question_spec.rb:9 # Question アソシエーションチェック answersと1対多の関係にある
rspec ./spec/models/question_spec.rb:13 # Question アソシエーションチェック 関連するanswersがあっても、questionを削除でき、answersも削除される
rspec ./spec/models/user_spec.rb:10 # User バリデーション 名前がない場合、無効である
rspec ./spec/models/user_spec.rb:16 # User バリデーション 名前が255文字以上場合、無効である
rspec ./spec/models/user_spec.rb:22 # User バリデーション メールアドレスがない場合、無効である
rspec ./spec/models/user_spec.rb:28 # User バリデーション 重複したメールアドレスの場合、無効である
rspec ./spec/models/user_spec.rb:35 # User バリデーション パスワードが2文字以下の場合、無効である
rspec ./spec/models/user_spec.rb:41 # User バリデーション パスワード(確認用)がない場合、無効である
rspec ./spec/models/user_spec.rb:47 # User バリデーション パスワード(確認用)がパスワードと一致しない場合、無効である
rspec ./spec/models/user_spec.rb:53 # User バリデーション notificaiton_enabledない場合、無効である
rspec ./spec/models/user_spec.rb:59 # User バリデーション line_user_idがblankの場合、重複していても有効である
rspec ./spec/models/user_spec.rb:66 # User バリデーション notification_enabledがenumで定義されている
rspec ./spec/models/user_spec.rb:81 # User アソシエーションチェック profilesとのアソシエーション profilesと1対多の関係にある
rspec ./spec/models/user_spec.rb:85 # User アソシエーションチェック profilesとのアソシエーション 関連するprofilesがあっても、userを削除でき、profilesも削除される
rspec ./spec/models/user_spec.rb:95 # User アソシエーションチェック groupsとのアソシエーション groupsと1対多の関係にある
rspec ./spec/models/user_spec.rb:99 # User アソシエーションチェック groupsとのアソシエーション 関連するgroupsがあっても、userを削除でき、groupsも削除される
rspec ./spec/models/user_spec.rb:109 # User アソシエーションチェック authenticationsとのアソシエーション authenticationsと1対多の関係にある
rspec ./spec/models/user_spec.rb:113 # User アソシエーションチェック authenticationsとのアソシエーション 関連するauthenticationsがあっても、userを削除でき、authenticationsも削除される
rspec ./spec/models/user_spec.rb:124 # User アソシエーションチェック eventsとのアソシエーション eventsと1対多の関係にある
rspec ./spec/models/user_spec.rb:128 # User アソシエーションチェック eventsとのアソシエーション 関連するeventsがあっても、userを削除でき、eventsも削除される
rspec ./spec/models/user_spec.rb:138 # User accepts_nested_attributes_for userモデルが更新される際、ネストされたauthenticationsの属性も保存する
rspec ./spec/models/user_spec.rb:154 # User メソッドのテスト LINE通知の対象ユーザーを取得する
config.use_transactional_fixtures = false
にする考え方は合っておりますでしょうか。
その場合、database_cleanerを使って各テスト前後にDBをクリーンにする必要があると考えております。
しかし、実装が複雑になる為、できれば原因をさらに絞り込み、他の手段で解決したいと思っております。 見るポイント、実行するコマンドなどありましたら、アドバイスいただけますと幸いです。
config.use_transactional_fixtures = falseにする考え方は合っておりますでしょうか。 その場合、database_cleanerを使って各テスト前後にDBをクリーンにする必要があると考えております。 しかし、実装が複雑になる為、できれば原因をさらに絞り込み、他の手段で解決したいと思っております。 見るポイント、実行するコマンドなどありましたら、アドバイスいただけますと幸いです。
一旦、期待している挙動(テストが通る状況)にするためなら、false&database_clanerを使う方法も良いかと思います。
また、上記はlet!で行ったのか、letで行ったのか、両方でも変化が無いのかなどを確認が必要かと思いました。
以下はChatGPTが返してきたテキストの概要の共有になります。
use_transactional_fixtures を false に設定する
# spec/rails_helper.rb
RSpec.configure do |config|
config.use_transactional_fixtures = false
# その他の設定
end
テストごとにデータベースをクリーンアップする設定を追加する
# spec/rails_helper.rb
RSpec.configure do |config|
# 上記の設定に加えて
config.before(:suite) do
# テストスイートの実行前にデータベースをクリーンアップ
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, type: :system) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
database_cleaner のインストール
# Gemfile
group :test do
gem 'database_cleaner-active_record'
end
database_cleaner を使わずにデータベースをリセットする方法
# spec/rails_helper.rb
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:each) do
ActiveRecord::Base.subclasses.each(&:delete_all)
end
end
結論
RSpecモデルテストを実行すると、
というエラーになり、詰まっております。
実装の目的
モデルテストを実行するため。
手順
私の行った手順は以下です。 (1)rspec-rails,factory_bot_rails Gemを開発とテスト環境にインストール (2)spec/modelsディレクトリ内にモデルテストのコードを記述 (3)
dc exec web bundle exec rspec spec/models
でローカルでモデルテストを実行実行環境・ソースコード
期待した結果
RSpecモデルテストが実行される。
実際の結果
実際は、以下のような結果になりました。
[エラーメッセージ]
なお、question_spec.rb は下記の通りに実装しています。
考えられる原因(仮説)
考えられる原因は
原因(仮説)の理由
This connection is in use by : #<Fiber:0x00007f735820dbe0 (resumed)>
というエラーメッセージより、接続が他のタスクと被ってしまっていると判断しました試したこと
以下を試しました。 (1)config/database.yml ファイルの、pool数を、5 --> 100へ変更
(2)RSpecテストで並列処理が行われるように設定されていないか確認
試したことの結果
試した結果このようになりました。 (1)同様のエラーが発生しました (2)-1. parallel_tests Gemがインストールされていないか確認 → されていませんでした。 Gemfile.lock
(2)-2. spec/rails_helper.rb, spec/spec_helper.rb設定ファイルを確認 → 並列処理の記述は見つかりませんでした spec/rails_helper.rb
spec/spec_helper.rb
お伺いしたいこと
原因の仮説は合っておりますでしょうか? 合っていれば、さらに深掘りするデバックの方法はありますでしょうか? また、見落としているファイルはございますでしょうか?