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

Track traits and overrides with FactoryProf #296

Conversation

lHydra
Copy link
Contributor

@lHydra lHydra commented May 20, 2024

What is the purpose of this pull request?

Add factory variants (such as traits/overrides) to the output in simple mode. This information will also be in the resulting json file.

Add variants_limit config parameter for FactoryProf to use special ID ([...]) for factories with too many traits/overrides. The default value is 2.

Is there anything you'd like reviewers to focus on?

  1. Do we need default values for the variations limit?
  2. Traits can still be long and accordingly the output gets messed up. I wanted to know if this is worth fixing, or is this behavior generally expected?

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation

Closes #292

@lHydra lHydra changed the title Track traits and overrides with factory prof Track traits and overrides with FactoryProf May 20, 2024
Copy link
Collaborator

@palkan palkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Let's move the other variation (...) check to the tracking method instead of dealing with this compressed_variations logic (and duplicating it).

We can use the :__other__ variation name for off limit variations and track it like that; only when we use the simple printer, we need to treat this key differently (show at the bottom of the variations list).

private

def compress_variations(variations, variations_limit)
limited_variation = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename it to other_variation

Copy link
Contributor Author

@lHydra lHydra Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/test_prof/factory_prof/factory_bot_patch.rb Outdated Show resolved Hide resolved
lib/test_prof/factory_prof/factory_builders/fabrication.rb Outdated Show resolved Hide resolved
lib/test_prof/factory_prof/factory_builders/factory_bot.rb Outdated Show resolved Hide resolved
@lHydra
Copy link
Contributor Author

lHydra commented May 23, 2024

Let's move the other variation (...) check to the tracking method instead of dealing with this compressed_variations logic (and duplicating it).

So we immediately write other variation (...) to the result if the limit is exceeded? I.e. if we export data to json, we also will see “compressed” data there?

@palkan
Copy link
Collaborator

palkan commented May 30, 2024

I.e. if we export data to json, we also will see “compressed” data there?

Good point. I think, for now it's okay to have "other" in the JSON output as well.

@lHydra lHydra force-pushed the track-traits-and-overrides-with-factory-prof branch from 97ea04a to c015654 Compare June 3, 2024 13:37
@lHydra lHydra requested a review from palkan June 3, 2024 13:45
@lHydra lHydra force-pushed the track-traits-and-overrides-with-factory-prof branch from c015654 to b4c7856 Compare June 5, 2024 13:49
@palkan
Copy link
Collaborator

palkan commented Jun 5, 2024

Thanks! Merged (via f1ee78b)

@palkan palkan closed this Jun 5, 2024
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.

Track traits and overrides with FactoryProf
2 participants