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

Ensure multiple anonymous modules are not included into test classes #35968

Conversation

shioyama
Copy link
Contributor

Similar to #35966. By the end of the tests here, the Topic class has something like five modules included in it. That doesn't seem like a very good idea.

I've used named subclasses then cleaned up by removing the constant, which is not ideal but better than polluting the original class.

@shioyama shioyama force-pushed the apply_acceptance_validator_to_subclasses_in_tests branch from 5381e29 to a50629a Compare April 14, 2019 08:10
@shioyama
Copy link
Contributor Author

Just as a note: I don't think the pattern of including modules each time validates :foo, acceptance: true is called on a class is a very good idea, although I understand the rationale for it. For now I just want to ensure the tests are clean, I'm going to see if I can improve that validator in a separate PR.

@shioyama shioyama changed the title Ensure multiple anonymous modules are not included into Topic in tests Ensure multiple anonymous modules are not included into test classes Apr 14, 2019
Each acceptance validator applied to a model class includes an instance
of a module builder (LazilyDefineAttributes) into that class. In tests,
if the original model class is not subclassed, these modules pile up and
cannot be removed, potentially leading to flakey specs and false
positive/negatives.

To avoid this, always use subclasses in tests whose names (constants)
can be removed when the test is done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants