Faker: Fake Text with Character Count

Created on 3 Nov 2017  路  8Comments  路  Source: faker-ruby/faker

Anyone ever dreamed of a lorem ipsum generator or somesuch that could be passed a character maximum count? Something like Hipster.paragraph_by_characters(256).

Use cases:

  • testing length validations
  • avoiding inadvertently hitting length validations on other tests
  • catch formatting and layout issues with very long entries if seeding with Faker data
Feature Request

Most helpful comment

I'm thinking it might make more sense to implement this as an optional argument to the paragraph methods rather than creating a new paragraph_by_chars method. It would also be nice to switch to named arguments for that approach. I've been wanting to do that for all of Faker.

All 8 comments

I think this is a good idea. Happy to do this one if people are keen.

Hi guys, sorry to jump in @keithbro , but I thought I'd have a shot at working this (newbie to opensource, and could do with the experience on a straight forward fix!)

Is the desire to have exactly N characters returned, or at least N characters returned?

The goal, in my mind, is to test around validations, so we might want an exact character count returned to make sure we can hit the max character validation / go over that limit on each test.

(I鈥檝e been using the Number library and just returning giant integers as a workaround that is functionally perfect but aesthetically meh)

I'm thinking it might make more sense to implement this as an optional argument to the paragraph methods rather than creating a new paragraph_by_chars method. It would also be nice to switch to named arguments for that approach. I've been wanting to do that for all of Faker.

I was originally going to go down the line of adding it to the existing paragraphs method (makes much more sense in my opinion than making a whole new method), but had the same thought of where to set the param. It gets a bit long winded once you've had to account for number of sentences, whether to include supplemental words etc, so essentially I'd agree that named params are the way to go.

We've reviewed the PR and merged it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elangovan-selvaraj picture elangovan-selvaraj  路  6Comments

vbrazo picture vbrazo  路  3Comments

CJAdeszko picture CJAdeszko  路  6Comments

benpolinsky picture benpolinsky  路  5Comments

KelseyDH picture KelseyDH  路  4Comments