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

Allows override properties with collection attribute #89

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

Conversation

acarvalho
Copy link

No description provided.

@aparra
Copy link
Member

aparra commented Oct 12, 2016

Hey @acarvalho. Thank you very much for your contribution. We really appreciate it.

Now we need to have a little chat about this feature. Well, I particularly don't like the approach to override multiple functions in a collection:

Student student = Fixture.from(Student.class).gimme("valid", new Rule() {{
  add("addresses[0].id", 123456L);
  add("addresses[0].city.name", "BH");
  add("addresses[0].city.neighborhoods[0].name", "Santa Efigênia");
  add("addresses[1].id", 123457L);
  add("addresses[2].id", 123458L);
}});

I prefer override all the list in this case, I guess this way is more maintainable:

Student student = Fixture.from(Student.class).gimme("valid", new Rule() {{
  add("addresses", Fixture.from(Address.class).gimme(3, "from-bh"));
}});

But I am talking about this specific usage. Please let me know more about how you are using it.

cc/ @ahirata @nykolaslima

@acarvalho
Copy link
Author

acarvalho commented Oct 17, 2016

Hey @aparra, thanks for your answer.

The idea of this new feature is not to override multiple functions in a collection but rather to override one single function in a collection inside others collections. Take a look at the code below.

 Student student = Fixture.from(Student.class).gimme("valid", new Rule() {{
   add("addresses[0].city.neighborhoods[0].name", "Santa Efigênia");
 }});

To override a name, today in the library, I need to create a new template for address, city and neighborhoods. If these templates were used in other tests that's ok but most of the time these templates are used only in a specific test.

I think that the function of an override attribute in a template was created to avoid the creation of unnecessary templates to keep the code clean. But this does not work for collections. So this PR is to allow this.

Any question just ping me.

Cheers,

cc/ @ahirata @nykolaslima

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