Hi, I’m upgrading Rails 5.2 to Rails 6.0 and run unit tests on CircleCI, everything works OK except the following errors. There are no such errors when running on my laptop, so I consider whether it is a problem in CircleCI. Is there any suggestion on how to debug the problem? Thanks
The error:
Failure/Error: candidate = constant.const_get(name)
NameError:
uninitialized constant #<Class:0x0000563e8e94c758>::Students
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:284:in `const_get'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:284:in `block in constantize'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:280:in `each'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:280:in `inject'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:280:in `constantize'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:622:in `get'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:653:in `constantize'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.4/lib/action_dispatch/http/request.rb:89:in `controller_class_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.4/lib/action_dispatch/http/parameters.rb:100:in `binary_params_for?'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.4/lib/action_dispatch/http/parameters.rb:91:in `set_binary_encoding'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.4/lib/action_dispatch/http/parameters.rb:69:in `path_parameters='
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-rails-4.0.1/lib/rspec/rails/example/view_example_group.rb:198:in `block (2 levels) in <module:ViewExampleGroup>'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:365:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:529:in `block in run_owned_hooks_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:528:in `each'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:528:in `run_owned_hooks_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:615:in `block in run_example_hooks_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:614:in `reverse_each'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:614:in `run_example_hooks_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:484:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:502:in `run_before_example'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:261:in `block in run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:508:in `block in with_around_and_singleton_context_hooks'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:465:in `block in with_around_example_hooks'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:486:in `block in run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:626:in `block in run_around_example_hooks_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-rails-4.0.1/lib/rspec/rails/adapters.rb:75:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:455:in `instance_exec'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:390:in `execute_with'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:629:in `run_around_example_hooks_for'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:486:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:465:in `with_around_example_hooks'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:508:in `with_around_and_singleton_context_hooks'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:259:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:644:in `block in run_examples'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:640:in `map'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:640:in `run_examples'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:606:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:607:in `block in run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:607:in `map'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/example_group.rb:607:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:121:in `map'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2067:in `with_suite_hooks'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:116:in `block in run_specs'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/reporter.rb:74:in `report'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:115:in `run_specs'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:89:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.10.1/exe/rspec:4:in `<top (required)>'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/bin/rspec:23:in `load'
/root/eduvo/openapply/vendor/bundle/ruby/2.6.0/bin/rspec:23:in `<top (required)>'
/usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `load'
/usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/lib/ruby/2.6.0/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/2.6.0/bundler/cli.rb:463:in `exec'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/local/lib/ruby/2.6.0/bundler/cli.rb:27:in `dispatch'
/usr/local/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/local/lib/ruby/2.6.0/bundler/cli.rb:18:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in <top (required)>'
/usr/local/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Showing full backtrace because every line was filtered out.
See docs for RSpec::Configuration#backtrace_exclusion_patterns and
RSpec::Configuration#backtrace_inclusion_patterns for more information.
The config
version: 2.1
jobs:
unit_test:
working_directory: ~/eduvo/openapply
parallelism: 8
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
EAGER_LOAD: true
RAILS_ENV: test
RACK_ENV: test
COVERAGE: true
docker:
- image: johnnylaitw/circle-ci-ruby-2.6.5-prince:latest
auth:
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
- image: circleci/mysql:5.7.27-ram
- image: circleci/redis
steps:
- restore_cache:
keys:
- source-v3-{{ .Branch }}-{{ .Revision }}
- checkout
- save_cache:
key: source-v3-{{ .Branch }}-{{ .Revision }}
paths:
- ".git"
- run: mkdir -p $CIRCLE_ARTIFACTS
# This is based on your 1.0 configuration file or project settings
- run: bundle config --local without production:staging:sandbox
- restore_cache:
keys:
- gem-cache-v3-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- gem-cache-v3-{{ arch }}-{{ .Branch }}
- gem-cache-v3
- run:
name: Gem Bundling
command: 'bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
--jobs=4 --retry=3'
- save_cache:
key: gem-cache-v3-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run: mv config/database.yml.example config/database.yml
- run: mv config/pspdfkit_jwt.pem.example config/pspdfkit_jwt.pem
- run: bundle exec rake db:create db:schema:load db:schema:cache:dump
- restore_cache:
keys:
- asset-cache-v3-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- asset-cache-v3-{{ arch }}-{{ .Branch }}
- asset-cache-v3-{{ arch }}
- asset-cache-v3
- save_cache:
key: asset-cache-v3-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- public/assets
- tmp/cache/assets/sprockets
- tmp/archives
- run:
shell: /bin/bash
name: Check Config Spec
command: bundle exec rspec spec/configs/config_spec.rb
- run:
shell: /bin/bash -O globstar
name: Running RSpec
command: bundle exec rspec
-p
--require support/rspec_exclude_features_pattern
--order rand
--color
--format progress
--format RspecJunitFormatter
--out /tmp/test-results/rspec/results.xml
$(circleci tests glob spec/{models,controllers,api,abilitites,carriers,decorators,extras,helpers,lib,mailers,presenters,requests,routing,serializers,services,support,uploaders,validators,views,workers}/**/*_spec.rb | circleci tests split --split-by=timings)
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/circleci-artifacts
- run:
name: Stash coverage results
command: |
mkdir coverage_results
cp -R coverage/.resultset.json coverage_results/.resultset-${CIRCLE_NODE_INDEX}-unit.json
- persist_to_workspace:
root: .
paths:
- coverage_results
FYI, the auto loading is set by config.autoloader = :classic
for compatibility with old code structure.