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

Make a sequence/1 function that generates a default string #66

Closed
paulcsmith opened this issue Dec 3, 2015 · 4 comments
Closed

Make a sequence/1 function that generates a default string #66

paulcsmith opened this issue Dec 3, 2015 · 4 comments
Milestone

Comments

@paulcsmith
Copy link
Contributor

A lot of times I just want a unique value like this:

title: sequence(:title, fn(n) -> "Title #{n}" end)
body: sequence(:comment_body, fn(n) -> "Comment Body #{n}" end)

For simple cases like this I think it would be helpful if you could do something like

title: sequence(:title) #generates "Title #{n}"
body: sequence(:comment_body) #generates "Comment Body #{n}"

Thoughts on this? Would it be better to use Faker or would this be useful?

@paulcsmith
Copy link
Contributor Author

And maybe the name could be different. Like gen_unique(:title) or something like that

@jsteiner
Copy link
Contributor

jsteiner commented Dec 3, 2015

I really like title: sequence(:title). Good idea!

I'd rather it be the same name (sequence) so it's easier to remember / there's less to learn.

@paulcsmith
Copy link
Contributor Author

Great! This is super easy to implement so I'll add that tomorrow :D

@paulcsmith
Copy link
Contributor Author

Actually it might make sense to simplify this and make the first arg a string. So you would do:

sequence("Title") # Generates "Title 1"
sequence("Comment Body") # Generate "Comment Body 1"

I think the key can be a binary so that might work better. Less indirection I think

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

No branches or pull requests

2 participants