six2six / fixture-factory

Generator fake objects from a template
Apache License 2.0
445 stars 88 forks source link

#gimme and #has with multiple templates #56

Closed nykolaslima closed 10 years ago

nykolaslima commented 10 years ago

I saw a few people asking for this feature, in Caelum's blog and in UOL.

With this PR we can use f-f like this: Fixture.from(User.class).gimme(2, "male", "female");

Fixture.of(User.class).addTemplate("valid", new Rule() {{
add("phones", has(2).of(Phone.class, "home", "mobile"));
}});

We still can pass only one template.

To make it possible, I need to change properties that use targetAttribute. It was: add("phones", has(2).of(Phone.class, "valid", "targetAttribute")); Now it is: add("phones", has(2).of(Phone.class, "valid").targetAttribute("targetAttribute"));