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

feature: Generate a spec file. #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

schwern
Copy link

@schwern schwern commented Dec 15, 2020

Unlike schema migrations, data migrations are easy to test but require a bit of special setup. This adds a spec file to the generator.

  • Loads the migration.
  • Sets up the a quiet migrator object.
  • Basic describe up/down blocks with subjects.

Closes #148

Sets up a migrator object suitable for testing, it's quiet.
@ilyakatz
Copy link
Owner

Good idea. However, what about the people who don't use rspec? Maybe there should be an env var or something that is set if you want to generate spec file? I there there is something in Rails itself about this, but don't remember exactly how it works there

@schwern
Copy link
Author

schwern commented Dec 15, 2020

Rails.configuration.generators.options[:rails] can be introspected to get the test_framework. I'll see about putting something together for minitest.

@ilyakatz
Copy link
Owner

ilyakatz commented Dec 16, 2020 via email

@ilyakatz
Copy link
Owner

ilyakatz commented Aug 2, 2022

@schwern are you still interested in implementing this?

@ngouy
Copy link

ngouy commented Nov 2, 2022

will give it a try someday
Would be really useful to have that

@schwern
Copy link
Author

schwern commented Nov 14, 2022

@schwern are you still interested in implementing this?

Sure. I'll have to reload it into my brain.

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.

Generate a spec file when a data_migration is generated
3 participants