Skip to content

Commit

Permalink
Fix: uninitialized constant User
Browse files Browse the repository at this point in the history
In the test setting Test (MONGOID, 3.1, mongoid_73.gemfile)

got this error:
SimpleCov failed with exit 1/home/runner/work/pluck_all/pluck_all/test/mongoid/support/seeds.rb:2:in `<top (required)>': uninitialized constant User (NameError)
  • Loading branch information
khiav reoy committed Jul 30, 2023
1 parent 8397085 commit 300047e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gemfiles/mongoid_73.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ source 'https://rubygems.org'

gem 'mongoid', '~> 7.3.3'

# We need zeitwerk for autoloading in Rails 7
# But zeitwerk required ruby >= 2.4.4, we cannot test it in ruby 2.3
# So we lock the version below 7
gem 'activesupport', '< 7'

group :test do
gem 'simplecov', '< 0.18'
end
Expand Down
4 changes: 4 additions & 0 deletions test/mongoid/support/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# frozen_string_literal: true

require 'rails_compatibility/setup_autoload_paths'
RailsCompatibility.setup_autoload_paths [File.expand_path('../models/', __FILE__)]

User.delete_all
User.create(name: 'Pearl Shi', age: 18)
User.create(name: 'Rumble Huang', age: 20)
Expand Down

0 comments on commit 300047e

Please sign in to comment.