Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load fixtures into any plain old Ruby? #100

Open
jakeonrails opened this issue Jan 14, 2025 · 1 comment
Open

How to load fixtures into any plain old Ruby? #100

jakeonrails opened this issue Jan 14, 2025 · 1 comment

Comments

@jakeonrails
Copy link

I'm trying to re-use Oaken fixtures in a Lookbook for presenting previews of Rails view components.

How do I load an Oaken seed like accounts.admin_user in a plain Ruby class? It seems like including the Oaken::TestSetup doesn't seem to work - it expects the including class to be a ActiveSupport::TestCase.

Or is there an Oaken class method I can call? Like Oaken.load(:accounts) or something?

@kaspth
Copy link
Owner

kaspth commented Jan 21, 2025

Hey, thanks for opening this! I definitely need to look into this more. It's a bit ironic because this is actually part of Oaken's design goals to support this kind of stuff, I just haven't quite fleshed it out yet.

I'm not too familiar with Lookbook and how it boots, but you can do stuff like this:

include Oaken::Seeds
seed "cases/lookbook"

def some_preview
  accounts.admin_user # Or Oaken::Seeds.accounts.admin_user
end

Or:

Oaken::Seeds.seed "cases/lookbook"

def some_preview
  Oaken::Seeds.accounts.admin_user
end

Then in db/seeds/cases/lookbook.rb, you can set up the models and relationships specific to previews.

I definitely need to think about this more. I probably need to fiddle more with Lookbook and/or what I intended for http://github.com/bullet-train-co/showcase

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

No branches or pull requests

2 participants