Skip to content

Commit

Permalink
🤖 Favor Rails.root to ensure correct path
Browse files Browse the repository at this point in the history
In CI we're seeing this error:

```
LoadError:
  cannot load such file -- /app/samvera/spec/hyrax-webapp/config/environment
```

The rails_helper is in the /app/samvera/spec directory and then it's
trying to load the environment from the hyrax-webapp directory within
its current directory.
  • Loading branch information
kirkkwang committed Apr 2, 2024
1 parent 0ae4622 commit 7e0e3ab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@

ENV["RAILS_ENV"] ||= "test"
# require File.expand_path('../config/environment', __dir__)
require File.expand_path("hyrax-webapp/config/environment", __dir__)
require Rails.root.join("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!
require "factory_bot_rails"
FactoryBot.definition_file_paths = [File.expand_path("spec/factories", HykuAddons::Engine.root)]
FactoryBot.find_definitions

if defined?(HykuAddons)
FactoryBot.definition_file_paths = [File.expand_path("spec/factories", HykuAddons::Engine.root)]
FactoryBot.find_definitions
end

# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
Expand Down

0 comments on commit 7e0e3ab

Please sign in to comment.