Skip to content

Improve spec_helper and rails_helper for Hyku 7 and shared specs#48

Closed
ShanaLMoore wants to merge 5 commits intomainfrom
spec-helper-rails-helper-improvements
Closed

Improve spec_helper and rails_helper for Hyku 7 and shared specs#48
ShanaLMoore wants to merge 5 commits intomainfrom
spec-helper-rails-helper-improvements

Conversation

@ShanaLMoore
Copy link
Copy Markdown
Contributor

@ShanaLMoore ShanaLMoore commented Mar 5, 2026

  • Boot Rails from knapsack rails_helper (after ENV) then require only webapp spec_helper
  • Set ENV to mirror hyrax-webapp test env; keep HYRAX_FLEXIBLE default false
  • Use config.fixture_paths (plural); add Hyrax + webapp factory paths
  • Set Hyrax Valkyrie test config; add DatabaseCleaner, Devise, Warden, ActiveJob includes

These changes were needed in downstream projects (pals, hyku up)

Summary

This PR updates the knapsack test setup so Rails boots once with ENV set before initializers, and so specs can use Hyrax shared examples and webapp factories. Summary of changes:

  • Boot order: The knapsack boots Rails from its own rails_helper (after setting ENV), then requires only the webapp spec_helper. The webapp rails_helper is no longer required, so Rails is not loaded twice and ENV is in place before any initializers run.
  • ENV: Test env is aligned with hyrax-webapp (HYKU_ADMIN_HOST, HYKU_ROOT_HOST, VALKYRIE_TRANSITION, HYRAX_ANALYTICS_REPORTING, etc.). HYRAX_FLEXIBLE keeps the Hyku default via ENV['HYRAX_FLEXIBLE'] ||= 'false'.
  • fixture_paths: Uses config.fixture_paths (plural), the current RSpec/Rails API, instead of the deprecated config.fixture_path.
  • Factory paths: Adds Hyrax shared spec factories and hyrax-webapp factories so specs can use shared examples (e.g. "a Hyrax::Work") and webapp factories.
  • Valkyrie test config: Sets Hyrax.config.admin_set_model and Hyrax.config.collection_model in test to match hyrax-webapp.
  • DatabaseCleaner, Devise, Warden, ApplicationHelper, ActiveJob: Adds DatabaseCleaner and the usual includes so controller, view, and feature specs work when knapsacks add those spec types.

Screenshots / Video

N/A (test configuration only).

Expected Behavior

  • Specs run with Rails booted once and ENV set before initializers.
  • Specs that use Hyrax shared examples or webapp factories can load them.
  • Controller, view, and feature specs have the same helpers as the webapp when those spec types are used.
  • Default flexible metadata behavior is unchanged; HYRAX_FLEXIBLE stays false unless a spec or .env sets it.

Notes

  • Existing knapsack specs should keep working. spec_helper now pulls in only the webapp spec_helper (WebMock, rspec-its, Valkyrie adapter, etc.), not the webapp rails_helper.

orangewolf and others added 4 commits November 15, 2025 15:10
- Boot Rails from knapsack rails_helper (after ENV) then require only webapp spec_helper
- Set ENV to mirror hyrax-webapp test env; keep HYRAX_FLEXIBLE default false
- Use config.fixture_paths (plural); add Hyrax + webapp factory paths
- Set Hyrax Valkyrie test config; add DatabaseCleaner, Devise, Warden, ActiveJob includes

Made-with: Cursor
Comment thread spec/rails_helper.rb Outdated
@ShanaLMoore ShanaLMoore closed this Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants