diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0b9c9632..be5acd6bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,18 @@ ### Chores ### Deprecation ### Documentation + +- [PR #1653](https://github.com/stympy/faker/pull/1653) Add /faker-ruby/faker-bot to README [@vbrazo](https://github.com/vbrazo) + ### Feature Request + +- [PR #1664](https://github.com/stympy/faker/pull/1664) Replace positional arguments with keyword arguments [@vbrazo](https://github.com/vbrazo) + ### Update/add locales +- [PR #1658](https://github.com/stympy/faker/pull/1658) Update Faker::Games::SuperSmashBros entries [@boardfish](https://github.com/boardfish) +- [PR #1649](https://github.com/stympy/faker/pull/1649) Remove mexicoMX [@vbrazo](https://github.com/vbrazo) + ------------------------------------------------------------------------------ ## [v1.9.6](https://github.com/stympy/faker/tree/1.9.6) (2019-07-05) diff --git a/doc/books/dune.md b/doc/books/dune.md index eb4ca66288..b031dfbdd8 100644 --- a/doc/books/dune.md +++ b/doc/books/dune.md @@ -11,9 +11,9 @@ Faker::Books::Dune.planet #=> "Caladan" Faker::Books::Dune.quote #=> "A dead man, surely, no longer requires that water." -Faker::Books::Dune.quote("baron_harkonnen") #=> "He who controls the spice, controls the universe!" +Faker::Books::Dune.quote(character: "baron_harkonnen") #=> "He who controls the spice, controls the universe!" Faker::Books::Dune.saying #=> "You do not beg the sun for mercy." -Faker::Books::Dune.saying("fremen") #=> "May thy knife chip and shatter." +Faker::Books::Dune.saying(source: "fremen") #=> "May thy knife chip and shatter." ``` diff --git a/doc/books/lovecraft.md b/doc/books/lovecraft.md index a73b33e233..c8bfa00527 100644 --- a/doc/books/lovecraft.md +++ b/doc/books/lovecraft.md @@ -2,7 +2,7 @@ ```ruby Faker::Books::Lovecraft.fhtagn #=> "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn" -Faker::Books::Lovecraft.fhtagn(3) #=> "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn" +Faker::Books::Lovecraft.fhtagn(number_of: 3) #=> "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn" Faker::Books::Lovecraft.deity #=> "Shub-Niggurath" @@ -14,28 +14,28 @@ Faker::Books::Lovecraft.word #=> "furtive" # Optional arguments: word_count=4, random_words_to_add=6 Faker::Books::Lovecraft.sentence #=> "Furtive antiquarian squamous dank cat loathsome amorphous lurk." -Faker::Books::Lovecraft.sentence(3) #=> "Daemoniac antediluvian fainted squamous comprehension gambrel nameless singular." -Faker::Books::Lovecraft.sentence(3, 1) #=> "Amorphous indescribable tenebrous." +Faker::Books::Lovecraft.sentence(word_count: 3) #=> "Daemoniac antediluvian fainted squamous comprehension gambrel nameless singular." +Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 1) #=> "Amorphous indescribable tenebrous." # Optional arguments: num=3, spaces_allowed = false Faker::Books::Lovecraft.words #=> ["manuscript", "abnormal", "singular"] -Faker::Books::Lovecraft.words(2) #=> ["daemoniac", "cat"] -Faker::Books::Lovecraft.words(2, true) #=> ["lurk", "charnel"] +Faker::Books::Lovecraft.words(num: 2) #=> ["daemoniac", "cat"] +Faker::Books::Lovecraft.words(num: 2, spaces_allowed: true) #=> ["lurk", "charnel"] # Optional arguments: sentence_count=3 Faker::Books::Lovecraft.sentences #=> ["Nameless loathsome decadent gambrel.", "Ululate swarthy immemorial cat madness gibbous unmentionable unnamable.", "Decadent antediluvian non-euclidean tentacles amorphous tenebrous."] -Faker::Books::Lovecraft.sentences(2) #=> ["Antediluvian amorphous unmentionable singular accursed squamous immemorial.", "Gambrel daemoniac gibbous stygian shunned ululate iridescence abnormal."] +Faker::Books::Lovecraft.sentences(sentence_count: 2) #=> ["Antediluvian amorphous unmentionable singular accursed squamous immemorial.", "Gambrel daemoniac gibbous stygian shunned ululate iridescence abnormal."] # Optional arguments: sentence_count=3, random_sentences_to_add=3 Faker::Books::Lovecraft.paragraph #=> "Squamous nameless daemoniac fungus ululate. Cyclopean stygian decadent loathsome manuscript tenebrous. Foetid abnormal stench. Dank non-euclidean comprehension eldritch. Charnel singular shunned lurk effulgence fungus." -Faker::Books::Lovecraft.paragraph(2) #=> "Decadent lurk tenebrous loathsome furtive spectral amorphous gibbous. Gambrel eldritch daemoniac cat madness comprehension stygian effulgence." -Faker::Books::Lovecraft.paragraph(2, 1) #=> "Stench cyclopean fainted antiquarian nameless. Antiquarian ululate tenebrous non-euclidean effulgence." +Faker::Books::Lovecraft.paragraph(sentence_count: 2) #=> "Decadent lurk tenebrous loathsome furtive spectral amorphous gibbous. Gambrel eldritch daemoniac cat madness comprehension stygian effulgence." +Faker::Books::Lovecraft.paragraph(sentence_count: 2, random_sentences_to_add: 1) #=> "Stench cyclopean fainted antiquarian nameless. Antiquarian ululate tenebrous non-euclidean effulgence." # Optional arguments: paragraph_count=3 Faker::Books::Lovecraft.paragraphs #=> ["Noisome daemoniac gibbous abnormal antediluvian. Unutterable fungus accursed stench noisome lurk madness indescribable. Antiquarian fungus gibbering lurk dank fainted. Hideous loathsome manuscript daemoniac lurk charnel foetid.", "Non-euclidean immemorial indescribable accursed furtive. Dank unnamable cyclopean tenebrous stench immemorial. Eldritch abnormal gibbering tenebrous. Singular accursed lurk.", "Charnel antediluvian unnamable cat blasphemous comprehension tenebrous. Nameless accursed amorphous unnamable stench. Squamous unnamable mortal accursed manuscript spectral gambrel amorphous. Shunned stygian charnel unutterable. Tenebrous ululate lurk amorphous unnamable."] -Faker::Books::Lovecraft.paragraphs(2) #=> ["Hideous amorphous manuscript antediluvian non-euclidean cat eldritch foetid. Stench squamous manuscript amorphous gibbering fainted gibbous. Accursed loathsome blasphemous iridescence antediluvian abnormal ululate manuscript. Singular manuscript gibbering decadent accursed indescribable.", "Tenebrous unnamable comprehension antediluvian lurk. Lurk spectral noisome gibbering. Furtive manuscript madness tenebrous daemoniac."] +Faker::Books::Lovecraft.paragraphs(paragraph_count: 2) #=> ["Hideous amorphous manuscript antediluvian non-euclidean cat eldritch foetid. Stench squamous manuscript amorphous gibbering fainted gibbous. Accursed loathsome blasphemous iridescence antediluvian abnormal ululate manuscript. Singular manuscript gibbering decadent accursed indescribable.", "Tenebrous unnamable comprehension antediluvian lurk. Lurk spectral noisome gibbering. Furtive manuscript madness tenebrous daemoniac."] # Optional arguments: chars=3, supplemental=false Faker::Books::Lovecraft.paragraph_by_chars #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho." -Faker::Books::Lovecraft.paragraph_by_chars(256) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." +Faker::Books::Lovecraft.paragraph_by_chars(chars: 256) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." ``` diff --git a/doc/default/alphanumeric.md b/doc/default/alphanumeric.md index c53a4c15eb..6f67bd3e4a 100644 --- a/doc/default/alphanumeric.md +++ b/doc/default/alphanumeric.md @@ -3,7 +3,7 @@ It might be available in the next version. ```ruby -Faker::Alphanumeric.alpha 10 #=> "zlvubkrwga" +Faker::Alphanumeric.alpha(char_count: 10) #=> "zlvubkrwga" -Faker::Alphanumeric.alphanumeric 10 #=> "3yfq2phxtb" +Faker::Alphanumeric.alphanumeric(char_count: 10) #=> "3yfq2phxtb" ``` diff --git a/doc/default/avatar.md b/doc/default/avatar.md index 069d05cdca..d376c04542 100644 --- a/doc/default/avatar.md +++ b/doc/default/avatar.md @@ -3,13 +3,13 @@ ```ruby Faker::Avatar.image #=> "https://robohash.org/sitsequiquia.png?size=300x300&set=set1" -Faker::Avatar.image("my-own-slug") #=> "https://robohash.org/my-own-slug.png?size=300x300&set=set1" +Faker::Avatar.image(slug: "my-own-slug") #=> "https://robohash.org/my-own-slug.png?size=300x300&set=set1" -Faker::Avatar.image("my-own-slug", "50x50") #=> "https://robohash.org/my-own-slug.png?size=50x50&set=set1" +Faker::Avatar.image(slug: "my-own-slug", size: "50x50") #=> "https://robohash.org/my-own-slug.png?size=50x50&set=set1" -Faker::Avatar.image("my-own-slug", "50x50", "jpg") #=> "https://robohash.org/my-own-slug.jpg?size=50x50&set=set1" +Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "jpg") #=> "https://robohash.org/my-own-slug.jpg?size=50x50&set=set1" -Faker::Avatar.image("my-own-slug", "50x50", "bmp") #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1" +Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "bmp") #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1" -Faker::Avatar.image("my-own-slug", "50x50", "bmp", "set1", "bg1") #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1&bgset=bg1" +Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "bmp", set: "set1", bgset: "bg1") #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1&bgset=bg1" ``` diff --git a/doc/default/bank.md b/doc/default/bank.md index b5ce1aa4f7..9c78ffb2c8 100644 --- a/doc/default/bank.md +++ b/doc/default/bank.md @@ -3,19 +3,17 @@ Faker::Bank.account_number #=> 6738582379 -Faker::Bank.account_number(13) #=> 673858237902 +Faker::Bank.account_number(digits: 13) #=> 673858237902 Faker::Bank.iban #=> "GB76DZJM33188515981979" # Optional argument bank_country_code # All countries should be supported -Faker::Bank.iban("be") #=> "BE6375388567752043" +Faker::Bank.iban(country_code: "be") #=> "BE6375388567752043" Faker::Bank.name #=> "ABN AMRO CORPORATE FINANCE LIMITED" Faker::Bank.routing_number #=> "729343831" -Faker::Bank.routing_number(true) #=> "22-3833/64805" - Faker::Bank.swift_bic #=> "AAFMGB21" ``` diff --git a/doc/default/boolean.md b/doc/default/boolean.md index 4bb4709a0b..251859aff4 100644 --- a/doc/default/boolean.md +++ b/doc/default/boolean.md @@ -6,5 +6,5 @@ Available since version 1.6.2. # Optional parameter: true_ratio=0.5 Faker::Boolean.boolean #=> true -Faker::Boolean.boolean(0.2) #=> false +Faker::Boolean.boolean(true_ratio: 0.2) #=> false ``` diff --git a/doc/default/chile_rut.md b/doc/default/chile_rut.md index 7c6c1b3715..cc0a73f8a2 100644 --- a/doc/default/chile_rut.md +++ b/doc/default/chile_rut.md @@ -9,7 +9,7 @@ Faker::ChileRut.full_rut #=> "30686957-4" Faker::ChileRut.rut #=> 11235813 # Returns rut between passed minimum rut and 99999999 -Faker::ChileRut.rut(20_890_156) #=> 31853211 +Faker::ChileRut.rut(min_rut: 20_890_156) #=> 31853211 # Every call to rut or full_rut generates a new random rut, so last_rut and dv # allows you to get the separated parts of the full rut without losing the already generated rut diff --git a/doc/default/code.md b/doc/default/code.md index cc83363a83..10166609ae 100644 --- a/doc/default/code.md +++ b/doc/default/code.md @@ -11,7 +11,7 @@ Faker::Code.rut #=> "91389184-8" Faker::Code.nric #=> "S5589083H" -Faker::Code.nric(27, 34) #=> S8505970Z +Faker::Code.nric(min_age: 27, max_age: 34) #=> S8505970Z Faker::Code.imei #= "546327785982623" diff --git a/doc/default/commerce.md b/doc/default/commerce.md index 9dc358bc93..cbcccc83bf 100644 --- a/doc/default/commerce.md +++ b/doc/default/commerce.md @@ -5,21 +5,21 @@ Faker::Commerce.color #=> "lavender" # Optional arguments max=3, fixed_amount=false Faker::Commerce.department #=> "Grocery, Health & Beauty" -Faker::Commerce.department(5) #=> "Grocery, Books, Health & Beauty" -Faker::Commerce.department(2, true) #=> "Books & Tools" +Faker::Commerce.department(max: 5) #=> "Grocery, Books, Health & Beauty" +Faker::Commerce.department(max: 2, fixed_amount: true) #=> "Books & Tools" Faker::Commerce.material #=> "Steel" Faker::Commerce.product_name #=> "Practical Granite Shirt" # Produces a Float by default -Faker::Commerce.price #=> 44.6 -Faker::Commerce.price(range = 0..10.0, as_string = true) #=> "2.18" +Faker::Commerce.price #=> 44.6 +Faker::Commerce.price(range: 0..10.0, as_string: true) #=> "2.18" # Generate a random promotion code. # Optional argument digits = 6 for number of random digits in suffix Faker::Commerce.promotion_code #=> "AmazingDeal829102" -Faker::Commerce.promotion_code(digits = 2) #=> "AmazingPrice57" +Faker::Commerce.promotion_code(digits: 2) #=> "AmazingPrice57" Faker::Commerce.material #=> "Plastic" ``` diff --git a/doc/default/date.md b/doc/default/date.md index ff7178e334..bacf31b697 100644 --- a/doc/default/date.md +++ b/doc/default/date.md @@ -8,11 +8,11 @@ Faker::Date.between(2.days.ago, Date.today) #=> "Wed, 24 Sep 2014" Faker::Date.between_except(1.year.ago, 1.year.from_now, Date.today) #=> "Wed, 24 Sep 2014" # Random date in the future (up to maximum of N days) -Faker::Date.forward(23) # => "Fri, 03 Oct 2014" +Faker::Date.forward(days: 23) # => "Fri, 03 Oct 2014" # Random date in the past (up to maximum of N days) -Faker::Date.backward(14) #=> "Fri, 19 Sep 2014" +Faker::Date.backward(days: 14) #=> "Fri, 19 Sep 2014" # Random birthday date (maximum age between 18 and 65) -Faker::Date.birthday(18, 65) #=> "Mar, 28 Mar 1986" +Faker::Date.birthday(min_age: 18, max_age: 65) #=> "Mar, 28 Mar 1986" ``` diff --git a/doc/default/demographic.md b/doc/default/demographic.md index e54e2fe9e5..70e1a77cfc 100644 --- a/doc/default/demographic.md +++ b/doc/default/demographic.md @@ -15,5 +15,5 @@ Faker::Demographic.sex #=> "Female" Faker::Demographic.height #=> "1.61" -Faker::Demographic.height(:imperial) #=> "6 ft, 2 in" +Faker::Demographic.height(unit: :imperial) #=> "6 ft, 2 in" ``` diff --git a/doc/default/file.md b/doc/default/file.md index 23cc1742c1..9e68ae47a8 100644 --- a/doc/default/file.md +++ b/doc/default/file.md @@ -8,14 +8,14 @@ Faker::File.extension #=> "mp3" Faker::File.mime_type #=> "application/pdf" # Optional arguments: dir, name, extension, directory_separator -Faker::File.file_name('path/to') #=> "path/to/something_random.jpg" -Faker::File.file_name('foo/bar', 'baz') #=> "foo/bar/baz.zip" -Faker::File.file_name('foo/bar', 'baz', 'doc') #=> "foo/bar/baz.doc" -Faker::File.file_name('foo/bar', 'baz', 'mp3', '\\') #=> "foo\bar\baz.mp3" +Faker::File.file_name(dir: 'path/to') #=> "path/to/something_random.jpg" +Faker::File.file_name(dir: 'foo/bar', name: 'baz') #=> "foo/bar/baz.zip" +Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'doc') #=> "foo/bar/baz.doc" +Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo\bar\baz.mp3" # Optional arguments: segment_count, root, directory_separator Faker::File.dir #=> "path/to/something_random" -Faker::File.dir(2) #=> "foo/bar" -Faker::File.dir(3, '/') #=> "/foo/bar/baz" -Faker::File.dir(3, nil, '\\') #=> "foo\bar\baz" +Faker::File.dir(segment_count: 2) #=> "foo/bar" +Faker::File.dir(segment_count: 3, root: directory_separator: '/') #=> "/foo/bar/baz" +Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "foo\bar\baz" ``` diff --git a/doc/default/fillmurray.md b/doc/default/fillmurray.md index 87963f059f..a6f315a943 100644 --- a/doc/default/fillmurray.md +++ b/doc/default/fillmurray.md @@ -5,7 +5,7 @@ Available since version 1.7.1. ```ruby Faker::Fillmurray.image #=> "http://www.fillmurray.com/300/300" -Faker::Fillmurray.image(true) #=> "http://www.fillmurray.com/g/300/300" +Faker::Fillmurray.image(grayscale: true) #=> "http://fillmurray.com/g/300/300" -Faker::Fillmurray.image(false, 200, 400) #=> "http://www.fillmurray.com/200/400" +Faker::Fillmurray.image(grayscale: false, width: 200, height: 400) #=> "http://fillmurray.com/200/400" ``` diff --git a/doc/default/finance.md b/doc/default/finance.md index c04d7981d6..3ee2a91805 100644 --- a/doc/default/finance.md +++ b/doc/default/finance.md @@ -8,6 +8,6 @@ Faker::Finance.credit_card(:mastercard, :visa) #=> "4448-8934-1277-7195" # Random vat_number Faker::Finance.vat_number #=> "BR38.395.329/2471-83" -Faker::Finance.vat_number('DE') #=> "DE593306671" -Faker::Finance.vat_number('ZA') #=> "ZA79494416181" +Faker::Finance.vat_number(country: 'DE') #=> "DE593306671" +Faker::Finance.vat_number(country: 'ZA') #=> "ZA79494416181" ``` diff --git a/doc/default/hipster.md b/doc/default/hipster.md index 1ee1e1f48e..041e52afd7 100644 --- a/doc/default/hipster.md +++ b/doc/default/hipster.md @@ -7,35 +7,35 @@ Faker::Hipster.word #=> "irony" # Optional arguments: num=3, supplemental=false, spaces_allowed = false Faker::Hipster.words #=> ["pug", "pitchfork", "chia"] -Faker::Hipster.words(4) #=> ["ugh", "cardigan", "poutine", "stumptown"] -Faker::Hipster.words(4, true) #=> ["iste", "seitan", "normcore", "provident"] -Faker::Hipster.words(4, true, true) #=> ["qui", "magni", "craft beer", "est"] +Faker::Hipster.words(num: 4) #=> ["ugh", "cardigan", "poutine", "stumptown"] +Faker::Hipster.words(num: 4, supplemental: true) #=> ["iste", "seitan", "normcore", "provident"] +Faker::Hipster.words(num: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"] # Optional arguments: word_count=4, supplemental=false, random_words_to_add=6 Faker::Hipster.sentence #=> "Park iphone leggings put a bird on it." -Faker::Hipster.sentence(3) #=> "Pour-over swag godard." -Faker::Hipster.sentence(3, true) #=> "Beard laboriosam sequi celiac." -Faker::Hipster.sentence(3, false, 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit." -Faker::Hipster.sentence(3, true, 4) #=> "Occaecati deleniti messenger bag meh crucifix autem." +Faker::Hipster.sentence(word_count: 3) #=> "Pour-over swag godard." +Faker::Hipster.sentence(word_count: 3, supplemental: true) #=> "Beard laboriosam sequi celiac." +Faker::Hipster.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit." +Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Occaecati deleniti messenger bag meh crucifix autem." # Optional arguments: sentence_count=3, supplemental=false Faker::Hipster.sentences #=> ["Godard pitchfork vinegar chillwave everyday 90's whatever.", "Pour-over artisan distillery street waistcoat.", "Salvia yr leggings franzen blue bottle."] -Faker::Hipster.sentences(1) #=> ["Before they sold out pinterest venmo umami try-hard ugh hoodie artisan."] -Faker::Hipster.sentences(1, true) #=> ["Et sustainable optio aesthetic et."] +Faker::Hipster.sentences(sentence_count: 1) #=> ["Before they sold out pinterest venmo umami try-hard ugh hoodie artisan."] +Faker::Hipster.sentences(sentence_count: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."] # Optional arguments: sentence_count=3, supplemental=false, random_sentences_to_add=3 Faker::Hipster.paragraph #=> "Migas fingerstache pbr&b tofu. Polaroid distillery typewriter echo tofu actually. Slow-carb fanny pack pickled direct trade scenester mlkshk plaid. Banjo venmo chambray cold-pressed typewriter. Fap skateboard intelligentsia." -Faker::Hipster.paragraph(2) #=> "Yolo tilde farm-to-table hashtag. Lomo kitsch disrupt forage +1." -Faker::Hipster.paragraph(2, true) #=> "Typewriter iste ut viral kombucha voluptatem. Sint voluptates saepe. Direct trade irony chia excepturi yuccie. Biodiesel esse listicle et quam suscipit." -Faker::Hipster.paragraph(2, false, 4) #=> "Selvage vhs chartreuse narwhal vinegar. Authentic vinyl truffaut carry vhs pop-up. Hammock everyday iphone locavore thundercats bitters vegan goth. Fashion axe banh mi shoreditch whatever artisan." -Faker::Hipster.paragraph(2, true, 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics." +Faker::Hipster.paragraph(sentence_count: 2) #=> "Yolo tilde farm-to-table hashtag. Lomo kitsch disrupt forage +1." +Faker::Hipster.paragraph(sentence_count: 2, supplemental: true) #=> "Typewriter iste ut viral kombucha voluptatem. Sint voluptates saepe. Direct trade irony chia excepturi yuccie. Biodiesel esse listicle et quam suscipit." +Faker::Hipster.paragraph(sentence_count: 2, supplemental: false, random_sentences_to_add: 4) #=> "Selvage vhs chartreuse narwhal vinegar. Authentic vinyl truffaut carry vhs pop-up. Hammock everyday iphone locavore thundercats bitters vegan goth. Fashion axe banh mi shoreditch whatever artisan." +Faker::Hipster.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics." # Optional arguments: paragraph_count=3, supplemental=false Faker::Hipster.paragraphs #=> ["Tilde microdosing blog cliche meggings. Intelligentsia five dollar toast forage yuccie. Master kitsch knausgaard. Try-hard everyday trust fund mumblecore.", "Normcore viral pickled. Listicle humblebrag swag tote bag. Taxidermy street hammock neutra butcher cred kale chips. Blog portland humblebrag trust fund irony.", "Single-origin coffee fixie cleanse tofu xoxo. Post-ironic tote bag ramps gluten-free locavore mumblecore hammock. Umami loko twee. Ugh kitsch before they sold out."] -Faker::Hipster.paragraphs(1) #=> ["Skateboard cronut synth +1 fashion axe. Pop-up polaroid skateboard asymmetrical. Ennui fingerstache shoreditch before they sold out. Tattooed pitchfork ramps. Photo booth yr messenger bag raw denim bespoke locavore lomo synth."] -Faker::Hipster.paragraphs(1, true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."] +Faker::Hipster.paragraphs(paragraph_count: 1) #=> ["Skateboard cronut synth +1 fashion axe. Pop-up polaroid skateboard asymmetrical. Ennui fingerstache shoreditch before they sold out. Tattooed pitchfork ramps. Photo booth yr messenger bag raw denim bespoke locavore lomo synth."] +Faker::Hipster.paragraphs(paragraph_count: 1, supplemental: true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."] # Optional arguments: chars=3, supplemental=false Faker::Hipster.paragraph_by_chars #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho." -Faker::Hipster.paragraph_by_chars(256, false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." +Faker::Hipster.paragraph_by_chars(chars: 256, supplemental: false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." ``` diff --git a/doc/default/internet.md b/doc/default/internet.md index 1af415e2bc..68e960a5c7 100644 --- a/doc/default/internet.md +++ b/doc/default/internet.md @@ -11,36 +11,36 @@ Faker::Internet.email('Janelle Santiago', '+') #=> janelle+santiago@becker.com" # Optional argument name=nil Faker::Internet.free_email #=> "freddy@gmail.com" -Faker::Internet.free_email('Nancy') #=> "nancy@yahoo.com" +Faker::Internet.free_email(: 'Nancy') #=> "nancy@yahoo.com" # Optional argument name=nil Faker::Internet.safe_email #=> "christelle@example.org" -Faker::Internet.safe_email('Nancy') #=> "nancy@example.net" +Faker::Internet.safe_email(name: 'Nancy') #=> "nancy@example.net" # Optional arguments specifier=nil, separators=%w(. _) Faker::Internet.username #=> "alexie" -Faker::Internet.username('Nancy') #=> "nancy" +Faker::Internet.username(specifier: 'Nancy') #=> "nancy" -Faker::Internet.username('Nancy Johnson', %w(. _ -)) #=> "johnson-nancy" +Faker::Internet.username(specifier: 'Nancy Johnson', separators: %w(. _ -)) #=> "johnson-nancy" # Optional arguments: min_length=5, max_length=8 -Faker::Internet.username(5..8) +Faker::Internet.username(specifier: 5..8) # Optional argument min_length=8 -Faker::Internet.username(8) +Faker::Internet.username(specifier: 8) # Optional arguments: min_length=8, max_length=16 Faker::Internet.password #=> "Vg5mSvY1UeRg7" -Faker::Internet.password(8) #=> "YfGjIk0hGzDqS0" +Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0" -Faker::Internet.password(10, 20) #=> "EoC9ShWd1hWq4vBgFw" +Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw" -Faker::Internet.password(10, 20, true) #=> "3k5qS15aNmG" +Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG" -Faker::Internet.password(10, 20, true, true) #=> "*%NkOnJsH4" +Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_chars: true) #=> "*%NkOnJsH4" Faker::Internet.domain_name #=> "effertz.info" @@ -64,21 +64,21 @@ Faker::Internet.ip_v6_cidr #=> "ac5f:d696:3807:1d72:2eb5:4e81:7d2b:e1df/78" # Optional argument prefix='' Faker::Internet.mac_address #=> "e6:0d:00:11:ed:4f" -Faker::Internet.mac_address('55:44:33') #=> "55:44:33:02:1d:9b" +Faker::Internet.mac_address(prefix: '55:44:33') #=> "55:44:33:02:1d:9b" # Optional arguments: host=domain_name, path="/#{username}", scheme=scheme Faker::Internet.url #=> "http://thiel.com/chauncey_simonis" -Faker::Internet.url('example.com') #=> "http://example.com/clotilde.swift" -Faker::Internet.url('example.com', '/foobar.html') #=> "http://example.com/foobar.html" +Faker::Internet.url(host: 'example.com') #=> "http://example.com/clotilde.swift" +Faker::Internet.url(host: 'example.com', path: '/foobar.html') #=> "http://example.com/foobar.html" # Optional arguments: words=nil, glue=nil Faker::Internet.slug #=> "pariatur_laudantium" -Faker::Internet.slug('foo bar') #=> "foo.bar" -Faker::Internet.slug('foo bar', '-') #=> "foo-bar" +Faker::Internet.slug(words: 'foo bar') #=> "foo.bar" +Faker::Internet.slug(words: 'foo bar', glue: '-') #=> "foo-bar" # Optional argument: vendor=nil Faker::Internet.user_agent #=> "Mozilla/5.0 (compatible; MSIE 9.0; AOL 9.7; AOLBuild 4343.19; Windows NT 6.1; WOW64; Trident/5.0; FunWebProducts)" -Faker::Internet.user_agent(:firefox) #=> "Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0" +Faker::Internet.user_agent(vendor: :firefox) #=> "Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0" Faker::Internet.uuid #=> "929ef6ef-b11f-38c9-111b-accd67a258b2" ``` diff --git a/doc/default/json.md b/doc/default/json.md index ef38a8460b..b951f58a5c 100644 --- a/doc/default/json.md +++ b/doc/default/json.md @@ -1,6 +1,6 @@ # Faker::Json -**shallow_json(width_int, options_hash)** -> JSON formated string +**shallow_json(width: width_int, options: options_hash)** -> JSON formated string Takes a width_int and options_hash where the number of key value pairs in the returned JSON string is equal to the width_int. @@ -16,7 +16,7 @@ with `Faker::` ```ruby -Faker::Json.shallow_json(3, key: 'RockBand.name', value: 'Seinfeld.quote') +Faker::Json.shallow_json(width: 3, options: { key: 'RockBand.name', value: 'Seinfeld.quote' }) # => {"Parliament Funkadelic":"They're real, and they're spectacular.", "Fleetwood Mac":"I'm not a lesbian. I hate men, but I'm not a lesbian.", @@ -26,7 +26,7 @@ Faker::Json.shallow_json(3, key: 'RockBand.name', value: 'Seinfeld.quote') something to eat - it's all been wrong."} ``` -**add_depth_to_json(JSON, width_int, options_hash)** -> JSON +**add_depth_to_json(json: JSON, width: width_int, options: options_hash)** -> JSON Functions exactly as `Json#shallow_json()` except it takes in a JSON as an additional argument and returns that JSON with new generated nested JSONs in @@ -34,17 +34,17 @@ place of the lowest nested values. It is important to note that the JSON must be a JSON and not a hash. ```ruby -json = Faker::Json.shallow_json(3, key: 'Name.first_name', value: 'Name.last_name') +json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.last_name' }) puts json # => {"Alisha":"Olson","Everardo":"DuBuque","Bridgette":"Turner"} -json2 = Faker::Json.add_depth_to_json(json, 2, key: 'Name.first_name', value: 'Name.last_name') +json2 = Faker::Json.add_depth_to_json(json: json, width: 2, options: { key: 'Name.first_name', value: 'Name.last_name' }) puts json2 # => {"Alisha":{"Daisy":"Trantow","Oda":"Haag"}, "Everardo":{"Javier":"Marvin","Eliseo":"Schuppe"}, "Bridgette":{"Jorge":"Kertzmann","Lelah":"MacGyver"}} - json3 = Faker::Json.add_depth_to_json(json2, 4, key: 'Name.first_name', value: 'Name.last_name') + json3 = Faker::Json.add_depth_to_json(json: json2, width: 4, options: { key: 'Name.first_name', value: 'Name.last_name' }) puts json3 # => {"Alisha": {"Daisy": diff --git a/doc/default/kpop.md b/doc/default/kpop.md index adcd83d5c2..e2947821ac 100644 --- a/doc/default/kpop.md +++ b/doc/default/kpop.md @@ -1,7 +1,6 @@ # Faker::Kpop ```ruby - Faker::Kpop.i_groups # 1990's og groups => "Seo Taiji and Boys" Faker::Kpop.ii_groups # 2000's groups => "Girls' Generation" @@ -13,5 +12,4 @@ Faker::Kpop.girl_groups # girl groups => "2NE1" Faker::Kpop.boy_bands # boy bands => "Exo" Faker::Kpop.solo # solo artists => "T.O.P" - ``` diff --git a/doc/default/lorem.md b/doc/default/lorem.md index 79d3311d8a..69235bcf41 100644 --- a/doc/default/lorem.md +++ b/doc/default/lorem.md @@ -5,52 +5,52 @@ Faker::Lorem.word #=> "repellendus" # Optional arguments: num=3, supplemental=false (words from a supplementary list of Lorem-like words) Faker::Lorem.words #=> ["dolores", "adipisci", "nesciunt"] -Faker::Lorem.words(4) #=> ["culpa", "recusandae", "aut", "omnis"] -Faker::Lorem.words(4, true) #=> ["colloco", "qui", "vergo", "deporto"] +Faker::Lorem.words(num: 4) #=> ["culpa", "recusandae", "aut", "omnis"] +Faker::Lorem.words(num: 4, supplemental: true) #=> ["colloco", "qui", "vergo", "deporto"] Faker::Lorem.multibyte #=> 😀 # Optional arguments: char_count=255 Faker::Lorem.characters #=> "uw1ep04lhs0c4d931n1jmrspprf5wrj85fefue0y7y6m56b6omquh7br7dhqijwlawejpl765nb1716idmp3xnfo85v349pzy2o9rir23y2qhflwr71c1585fnynguiphkjm8p0vktwitcsm16lny7jzp9t4drwav3qmhz4yjq4k04x14gl6p148hulyqioo72tf8nwrxxcclfypz2lc58lsibgfe5w5p0xv95peafjjmm2frkhdc6duoky0aha" -Faker::Lorem.characters(10) #=> "ang9cbhoa8" +Faker::Lorem.characters(char_count: 10) #=> "ang9cbhoa8" # Optional arguments: word_count=4, supplemental=false, random_words_to_add=0 # The 'random_words_to_add' argument increases the sentence's word count by a random value within (0..random_words_to_add). # To specify an exact word count for a sentence, set word_count to the number you want and random_words_to_add equal to 0. # By default, sentences will not have any random words added (and will all be exactly 4 words long) Faker::Lorem.sentence #=> "Quia illum libero magni." -Faker::Lorem.sentence(3) #=> "Quaerat quam unde." -Faker::Lorem.sentence(3, true) #=> "Vehemens velit cogo." -Faker::Lorem.sentence(3, false, 4) #=> "Aut voluptatem illum fugit ut sit." -Faker::Lorem.sentence(3, true, 4) #=> "Accusantium tantillus dolorem timor." +Faker::Lorem.sentence(word_count: 3) #=> "Quaerat quam unde." +Faker::Lorem.sentence(word_count: 3, supplemental: true) #=> "Vehemens velit cogo." +Faker::Lorem.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Aut voluptatem illum fugit ut sit." +Faker::Lorem.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Accusantium tantillus dolorem timor." # Optional arguments: sentence_count=3, supplemental=false Faker::Lorem.sentences #=> ["Vero earum commodi soluta.", "Quaerat fuga cumque et vero eveniet omnis ut.", "Cumque sit dolor ut est consequuntur."] -Faker::Lorem.sentences(1) #=> ["Ut perspiciatis explicabo possimus doloribus enim quia."] -Faker::Lorem.sentences(1, true) #=> ["Quis capillus curo ager veritatis voro et ipsum."] +Faker::Lorem.sentences(sentence_count: 1) #=> ["Ut perspiciatis explicabo possimus doloribus enim quia."] +Faker::Lorem.sentences(sentence_count: 1, supplemental: true) #=> ["Quis capillus curo ager veritatis voro et ipsum."] # Optional arguments: sentence_count=3, supplemental=false, random_sentences_to_add=0 # The 'random_sentences_to_add' argument increases the paragraph's sentence count by a random value within (0..random_sentences_to_add). # To specify an exact sentence count for a paragraph, set sentence_count to the number you want and random_sentences_to_add equal to 0. # By default, sentences will have a random number of words within the range (3..6). Faker::Lorem.paragraph #=> "Recusandae minima consequatur. Expedita sequi blanditiis. Ut fuga et." -Faker::Lorem.paragraph(2) #=> "Ducimus mollitia deserunt. Dicta et corporis." -Faker::Lorem.paragraph(2, true) #=> "Strues amplitudo dignissimos. Ver trucido charisma." -Faker::Lorem.paragraph(2, false, 4) #=> "Neque aut et nemo aut incidunt voluptates. Dolore cum est sint est. Vitae assumenda porro odio dolores fugiat. Est voluptatum quia rerum." -Faker::Lorem.paragraph(2, true, 4) #=> "Vomito unde uxor annus. Et patior utilis sursum." +Faker::Lorem.paragraph(sentence_count: 2) #=> "Ducimus mollitia deserunt. Dicta et corporis." +Faker::Lorem.paragraph(sentence_count: 2, supplemental: true) #=> "Strues amplitudo dignissimos. Ver trucido charisma." +Faker::Lorem.paragraph(sentence_count: 2, supplemental: false, 4) #=> "Neque aut et nemo aut incidunt voluptates. Dolore cum est sint est. Vitae assumenda porro odio dolores fugiat. Est voluptatum quia rerum." +Faker::Lorem.paragraph(sentence_count: 2, supplemental: true, 4) #=> "Vomito unde uxor annus. Et patior utilis sursum." # Optional arguments: paragraph_count=3, supplemental=false Faker::Lorem.paragraphs #=> ["Dolores quis quia ad quo voluptates. Maxime delectus totam numquam. Necessitatibus vel atque qui dolore.", "Id neque nemo. Dolores iusto facere est ad. Accusamus ipsa dolor ut.", "Et officiis ut hic. Sunt asperiores minus distinctio debitis ipsa dolor. Minima eos deleniti."] -Faker::Lorem.paragraphs(1) #=> ["Labore voluptas sequi. Ratione nulla eaque quia molestiae fugit. At quam laboriosam aut ut dignissimos."] -Faker::Lorem.paragraphs(1, true) #=> ["Depulso animi cunctatio amicitia adficio. Vester viduo qui despirmatio voluptas. Validus laudantium adopto ut agnitio venustas. Aer arcus odio esse."] +Faker::Lorem.paragraphs(paragraph_count: 1) #=> ["Labore voluptas sequi. Ratione nulla eaque quia molestiae fugit. At quam laboriosam aut ut dignissimos."] +Faker::Lorem.paragraphs(paragraph_count: 1, supplemental: true) #=> ["Depulso animi cunctatio amicitia adficio. Vester viduo qui despirmatio voluptas. Validus laudantium adopto ut agnitio venustas. Aer arcus odio esse."] # Optional arguments: word_count=4, supplemental=false, random_words_to_add=0 Faker::Lorem.question #=> "Vero eum dolore qui?" # Optional arguments: question_count=3, supplemental=false -Faker::Lorem.questions(3) #=> ["Ratione eaque doloremque?", "Qui aliquid fuga?", "Est cum ipsum?"] +Faker::Lorem.questions(question_count: 3) #=> ["Ratione eaque doloremque?", "Qui aliquid fuga?", "Est cum ipsum?"] # Optional arguments: chars=3, supplemental=false Faker::Lorem.paragraph_by_chars #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho." -Faker::Lorem.paragraph_by_chars(256, false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." +Faker::Lorem.paragraph_by_chars(chars: 256, supplemental: false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green." ``` diff --git a/doc/default/lorem_flickr.md b/doc/default/lorem_flickr.md index 60f4513a14..62f60619a7 100644 --- a/doc/default/lorem_flickr.md +++ b/doc/default/lorem_flickr.md @@ -5,43 +5,43 @@ Available since version 1.9.0. ```ruby Faker::LoremFlickr.image #=> "http://loremflickr.com/300/300" -Faker::LoremFlickr.image("50x60") #=> "http://loremflickr.com/50/60" +Faker::LoremFlickr.image(size: "50x60") #=> "http://loremflickr.com/50/60" -Faker::LoremFlickr.image("50x60", ['sports']) #=> "http://loremflickr.com/50/60/sports" +Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports']) #=> "http://loremflickr.com/50/60/sports" -Faker::LoremFlickr.image("50x60", ['sports', 'fitness']) #=> "http://loremflickr.com/50/60/sports,fitness" +Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "http://loremflickr.com/50/60/sports,fitness" -Faker::LoremFlickr.image("50x60", ['sports', 'fitness'], true) #=> "http://loremflickr.com/50/60/sports,fitness/all" +Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "http://loremflickr.com/50/60/sports,fitness/all" Faker::LoremFlickr.grayscale_image #=> "http://loremflickr.com/g/300/300/all" -Faker::LoremFlickr.grayscale_image("50x60") #=> "http://loremflickr.com/g/50/60/all" +Faker::LoremFlickr.grayscale_image(size: "50x60") #=> "http://loremflickr.com/g/50/60/all" -Faker::LoremFlickr.grayscale_image("50x60", ['sports']) #=> "http://loremflickr.com/g/50/60/sports" +Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports']) #=> "http://loremflickr.com/g/50/60/sports" -Faker::LoremFlickr.grayscale_image("50x60", ['sports', 'fitness']) #=> "http://loremflickr.com/g/50/60/sports,fitness" +Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "http://loremflickr.com/g/50/60/sports,fitness" -Faker::LoremFlickr.grayscale_image("50x60", ['sports', 'fitness'], true) #=> "http://loremflickr.com/g/50/60/sports,fitness/all" +Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "http://loremflickr.com/g/50/60/sports,fitness/all" Faker::LoremFlickr.pixelated_image #=> "http://loremflickr.com/p/300/300/all" -Faker::LoremFlickr.pixelated_image("50x60") #=> "http://loremflickr.com/p/50/60/all" +Faker::LoremFlickr.pixelated_image(size: "50x60") #=> "http://loremflickr.com/p/50/60/all" -Faker::LoremFlickr.pixelated_image("50x60", ['sports']) #=> "http://loremflickr.com/p/50/60/sports" +Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports']) #=> "http://loremflickr.com/p/50/60/sports" -Faker::LoremFlickr.pixelated_image("50x60", ['sports', 'fitness']) #=> "http://loremflickr.com/p/50/60/sports,fitness" +Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "http://loremflickr.com/p/50/60/sports,fitness" -Faker::LoremFlickr.pixelated_image("50x60", ['sports', 'fitness'], true) #=> "http://loremflickr.com/p/50/60/sports,fitness/all" +Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "http://loremflickr.com/p/50/60/sports,fitness/all" Faker::LoremFlickr.colorized_image #=> "http://loremflickr.com/red/300/300/all" -Faker::LoremFlickr.colorized_image("50x60") #=> "http://loremflickr.com/red/50/60/all" +Faker::LoremFlickr.colorized_image(size: "50x60") #=> "http://loremflickr.com/red/50/60/all" -Faker::LoremFlickr.colorized_image("50x60", 'red') #=> "http://loremflickr.com/red/50/60/all" +Faker::LoremFlickr.colorized_image(size: "50x60", color: 'red') #=> "http://loremflickr.com/red/50/60/all" -Faker::LoremFlickr.colorized_image("50x60", 'red', ['sports']) #=> "http://loremflickr.com/red/50/60/sports" +Faker::LoremFlickr.colorized_image(size: "50x60", color: 'red', search_terms: ['sports']) #=> "http://loremflickr.com/red/50/60/sports" -Faker::LoremFlickr.colorized_image("50x60", 'red', ['sports', 'fitness']) #=> "http://loremflickr.com/red/50/60/sports,fitness" +Faker::LoremFlickr.colorized_image(size: "50x60", color: 'red', search_terms: ['sports', 'fitness']) #=> "http://loremflickr.com/red/50/60/sports,fitness" -Faker::LoremFlickr.colorized_image("50x60", 'red', ['sports', 'fitness'], true) #=> "http://loremflickr.com/red/50/60/sports,fitness/all" +Faker::LoremFlickr.colorized_image(size: "50x60", color: 'red', search_terms: ['sports', 'fitness'], match_all: true) #=> "http://loremflickr.com/red/50/60/sports,fitness/all" ``` diff --git a/doc/default/lorem_pixel.md b/doc/default/lorem_pixel.md index 7951318f87..4e942ba167 100644 --- a/doc/default/lorem_pixel.md +++ b/doc/default/lorem_pixel.md @@ -5,17 +5,17 @@ Available since version 1.7.0. ```ruby Faker::LoremPixel.image #=> "https://lorempixel.com/300/300" -Faker::LoremPixel.image("50x60") #=> "https://lorempixel.com/50/60" +Faker::LoremPixel.image(size: "50x60") #=> "https://lorempixel.com/50/60" -Faker::LoremPixel.image("50x60", true) #=> "https://lorempixel.com/g/50/60" +Faker::LoremPixel.image(size: "50x60", is_gray: true) #=> "https://lorempixel.com/g/50/60" -Faker::LoremPixel.image("50x60", false, 'sports') #=> "https://lorempixel.com/50/60/sports" +Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports') #=> "https://lorempixel.com/50/60/sports" -Faker::LoremPixel.image("50x60", false, 'sports', 3) #=> "https://lorempixel.com/50/60/sports/3" +Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3) #=> "https://lorempixel.com/50/60/sports/3" -Faker::LoremPixel.image("50x60", false, 'sports', 3, 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/3/Dummy-text" +Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/3/Dummy-text" -Faker::LoremPixel.image("50x60", false, 'sports', nil, 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/Dummy-text" +Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: nil, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/Dummy-text" Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300" ``` diff --git a/doc/default/markdown.md b/doc/default/markdown.md index 8816eedde0..28682b96f6 100644 --- a/doc/default/markdown.md +++ b/doc/default/markdown.md @@ -36,7 +36,7 @@ Faker::Markdown.random("ordered_list", "unordered_list") #=> returns output from # Sandwich - creates a simulated blog-esque text-heavy block in markdown Faker::Markdown.sandwich #=> returns newline separated content of 1 header, 1 default lorem paragraph, and 1 random markdown element -Faker::Markdown.sandwich(5) #=> returns newline separated content of 1 header, 1 5-sentence lorem paragraph, and 1 random markdown element +Faker::Markdown.sandwich(sentences: 5) #=> returns newline separated content of 1 header, 1 5-sentence lorem paragraph, and 1 random markdown element -Faker::Markdown.sandwich(6, 3) #=> returns newline separated content of 1 header, and then 3 sections consisting of, here, 1 6-sentence lorem paragraph and 1 random markdown element. The random markdown element is chosen at random in each iteration of the paragraph-markdown pairing. +Faker::Markdown.sandwich(sentences: 6, repeat: 3) #=> returns newline separated content of 1 header, and then 3 sections consisting of, here, 1 6-sentence lorem paragraph and 1 random markdown element. The random markdown element is chosen at random in each iteration of the paragraph-markdown pairing. ``` diff --git a/doc/default/measurement.md b/doc/default/measurement.md index 8501b0ccd5..7e5ed183bc 100644 --- a/doc/default/measurement.md +++ b/doc/default/measurement.md @@ -7,11 +7,11 @@ ```ruby Faker::Measurement.height #=> "6 inches" -Faker::Measurement.height(1.4) #=> "1.4 inches" +Faker::Measurement.height(amount: 1.4) #=> "1.4 inches" -Faker::Measurement.height("none") #=> "inch" +Faker::Measurement.height(amount: "none") #=> "inch" -Faker::Measurement.height("all") #=> "inches" +Faker::Measurement.height(amount: "all") #=> "inches" Faker::Measurement.length #=> "1 yard" diff --git a/doc/default/name.md b/doc/default/name.md index 82c7f6fbb0..bf229774e9 100644 --- a/doc/default/name.md +++ b/doc/default/name.md @@ -20,5 +20,5 @@ Faker::Name.prefix #=> "Mr." Faker::Name.suffix #=> "IV" Faker::Name.initials #=> "NJM" -Faker::Name.initials(2) #=> "NM" +Faker::Name.initials(character_count: 2) #=> "NM" ``` diff --git a/doc/default/national_health_service.md b/doc/default/national_health_service.md index edced2e8a9..48db25be29 100644 --- a/doc/default/national_health_service.md +++ b/doc/default/national_health_service.md @@ -5,5 +5,5 @@ It might be available in the next version ```ruby Faker::NationalHealthService.british_number #=> "403 958 5577" -Faker::NationalHealthService.check_digit(400_012_114) #=> 6 +Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6 ``` diff --git a/doc/default/number.md b/doc/default/number.md index 7586282750..6d75477cf0 100644 --- a/doc/default/number.md +++ b/doc/default/number.md @@ -3,36 +3,36 @@ ```ruby # Required parameter: digits # Produces a number of the specified digits where the leading digit is never 0 -Faker::Number.number(10) #=> 1968353479 +Faker::Number.number(digits: 10) #=> 1968353479 # Required parameter: digits # Produces a number of the specified digits with a leading zero -Faker::Number.leading_zero_number(10) #=> "0669336915" +Faker::Number.leading_zero_number(digits: 10) #=> "0669336915" # Required parameter: digits # Produces a 2-digit number, preserves leading 0's -Faker::Number.decimal_part(2) #=> "09" +Faker::Number.decimal_part(digits: 2) #=> "09" # Required parameter: l_digits # Produces a number with 2 digits leading and trailing the decimal -Faker::Number.decimal(2) #=> 11.88 +Faker::Number.decimal(l_digits: 2) #=> 11.88 # Specify different values for leading and trailing digits -Faker::Number.decimal(3, 3) #=> 181.843 +Faker::Number.decimal(l_digits: 3, r_digits: 3) #=> 181.843 # Required parameters: mean, standard_deviation -Faker::Number.normal(50, 3.5) #=> 47.14669604069156 +Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156 # Required parameter: digits -Faker::Number.hexadecimal(3) #=> "e74" +Faker::Number.hexadecimal(digits: 3) #=> "e74" # Required parameters: minimum value, maximum value # Boundary numbers are inclusive -Faker::Number.between(1, 10) #=> 7 +Faker::Number.between(from: 1, to: 10) #=> 7 # Required parameters: a range value # Min and Max boundaries of range are inclusive -Faker::Number.within(1..10) #=> 7 +Faker::Number.within(range: 1..10) #=> 7 Faker::Number.positive #=> 235.59238499107653 diff --git a/doc/default/phone_number.md b/doc/default/phone_number.md index 2b4fef6382..6b341bc348 100644 --- a/doc/default/phone_number.md +++ b/doc/default/phone_number.md @@ -34,13 +34,13 @@ Faker::PhoneNumber.exchange_code #=> "208" # Optional parameter: length=4 Faker::PhoneNumber.subscriber_number #=> "3873" -Faker::PhoneNumber.subscriber_number(2) #=> "39" +Faker::PhoneNumber.subscriber_number(length: 2) #=> "39" Faker::PhoneNumber.extension #=> "3764" Faker::PhoneNumber.country_code #=> "+20" -Faker::PhoneNumber.phone_number_with_country_code #=> "+95 1-672-173-8153" +Faker::PhoneNumber.phone_number_with_country_code #=> "+95 1-672-173-8153" -Faker::PhoneNumber.cell_phone_with_country_code #=> "+974 (190) 987-9034" +Faker::PhoneNumber.cell_phone_with_country_code #=> "+974 (190) 987-9034" ``` diff --git a/doc/default/placeholdit.md b/doc/default/placeholdit.md index 75b3c1a983..4798908ad2 100644 --- a/doc/default/placeholdit.md +++ b/doc/default/placeholdit.md @@ -3,19 +3,19 @@ ```ruby Faker::Placeholdit.image #=> "https://placehold.it/300x300.png" -Faker::Placeholdit.image('50x50') #=> "https://placehold.it/50x50.png" +Faker::Placeholdit.image(size: '50x50') #=> "https://placehold.it/50x50.png" -Faker::Placeholdit.image('50x50', 'jpg') #=> "https://placehold.it/50x50.jpg" +Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://placehold.it/50x50.jpg" -Faker::Placeholdit.image('50x50', 'gif', 'ffffff') #=> "https://placehold.it/50x50.gif/ffffff" +Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://placehold.it/50x50.gif/ffffff" -Faker::Placeholdit.image('50x50', 'jpeg', :random) #=> "https://placehold.it/50x50.jpeg/39eba7" +Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://placehold.it/50x50.jpeg/39eba7" -Faker::Placeholdit.image('50x50', 'jpeg', 'ffffff', '000') #=> "https://placehold.it/50x50.jpeg/ffffff/000" +Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://placehold.it/50x50.jpeg/ffffff/000" -Faker::Placeholdit.image('50x50', 'jpeg', :random, :random) #=> "https://placehold.it/50x50.jpeg/d39e44/888ba7" +Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random, :random) #=> "https://placehold.it/50x50.jpeg/d39e44/888ba7" -Faker::Placeholdit.image('50x50', 'jpg', 'ffffff', '000', 'Some Custom Text') #=> "https://placehold.it/50x50.jpg/ffffff/000?text=Some Custom Text" +Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://placehold.it/50x50.jpg/ffffff/000?text=Some Custom Text" ``` ## Tips @@ -23,10 +23,10 @@ Faker::Placeholdit.image('50x50', 'jpg', 'ffffff', '000', 'Some Custom Text') #= If you want to have this file downloaded, like in your tests, you could use this following piece of code: ```ruby -def image_file(size = '300x300', format = 'png', background_color = nil, text_color = nil, text = nil) +def image_file(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil) file = Tempfile.new("faker_placeholdit") file.binmode - file << Net::HTTP.get(URI(Faker::Placeholdit.image(size, format, background_color, text_color, text))) + file << Net::HTTP.get(URI(Faker::Placeholdit.image(size: size, format: format, background_color: background_color, text_color: text_color, text: text))) file.close ::File.new(file.path) diff --git a/doc/default/relationship.md b/doc/default/relationship.md index 63be1388d5..ce42dbf388 100644 --- a/doc/default/relationship.md +++ b/doc/default/relationship.md @@ -6,9 +6,9 @@ It might be available in the next version. ```ruby Faker::Relationship.familial #=> "Mother" or "Grandmother" -Faker::Relationship.familial('direct') #=> "Mother" or "Brother" +Faker::Relationship.familial(connection: 'direct') #=> "Mother" or "Brother" -Faker::Relationship.familial('extended') #=> "Grandmother" or "Niece" or "Aunt" +Faker::Relationship.familial(connection: 'extended') #=> "Grandmother" or "Niece" or "Aunt" Faker::Relationship.spouse #=> "Husband" or "Wife" diff --git a/doc/default/source.md b/doc/default/source.md index aa5af28361..5b1fad824a 100644 --- a/doc/default/source.md +++ b/doc/default/source.md @@ -6,11 +6,11 @@ It might be available in the next version. ```ruby # Optional argument: lang=:ruby Faker::Source.hello_world #=> "print 'Hello World!'" -Faker::Source.hello_world(:javascript) #=> "alert('Hello World!');" +Faker::Source.hello_world(lang: :javascript) #=> "alert('Hello World!');" # Optional arguments: str='some string', lang=:ruby Faker::Source.print #=> "print 'some string'" -Faker::Source.print('cake') #=> "print 'cake'" +Faker::Source.print(str: 'cake') #=> "print 'cake'" Faker::Source.print(str: 'cake', lang: :javascript) #=> "console.log('cake');" # Optional argument: lang=:ruby @@ -19,7 +19,7 @@ Faker::Source.print_1_to_10 <<-DOC=> " print i end" DOC -Faker::Source.print_1_to_10(:javascript) <<-DOC=> " +Faker::Source.print_1_to_10(lang: :javascript) <<-DOC=> " for (let i=0; i<10; i++) { console.log(i); }" diff --git a/doc/default/string.md b/doc/default/string.md index 5c43dc203d..20d141d558 100644 --- a/doc/default/string.md +++ b/doc/default/string.md @@ -3,8 +3,8 @@ Random UTF-8 string with optional nested length selectors. Very useful for test ```ruby Faker::String.random #=> "3 뇦\u0017&y\u{3A109}$8^4* 녹豿4좘툢ꔾ쉙6ɉ\uA6 8TN畀챵|\"3쇤Ŵ" -Faker::String.random(4) #=> "⼨%0*" -Faker::String.random(3..12) #=> "\u{69FDC};秨툫" -Faker::String.random([0, 6]) #=> "I轤𣴒P溟L" -Faker::String.random([1, (2..5), [3, 6], nil]) #=> "葓L#ћ" +Faker::String.random(length: 4) #=> "⼨%0*" +Faker::String.random(length: 3..12) #=> "\u{69FDC};秨툫" +Faker::String.random(length: [0, 6]) #=> "I轤𣴒P溟L" +Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ" ``` diff --git a/doc/default/stripe.md b/doc/default/stripe.md index d8a08835ba..4ecfe113be 100644 --- a/doc/default/stripe.md +++ b/doc/default/stripe.md @@ -5,15 +5,15 @@ Test Stripe transactions without hardcoding card numbers and tokens ```ruby Faker::Stripe.valid_card #=> "4242424242424242" -Faker::Stripe.valid_card("visa_debit") #=> "4000056655665556" +Faker::Stripe.valid_card(card_type: "visa_debit") #=> "4000056655665556" Faker::Stripe.valid_token #=> "tok_visa" -Faker::Stripe.valid_token("mc_debit") #=> "tok_mastercard_debit" +Faker::Stripe.valid_token(card_type: "mc_debit") #=> "tok_mastercard_debit" Faker::Stripe.invalid_card #=> "4000000000000002" -Faker::Stripe.invalid_card("addressZipFail") #=> "4000000000000010" +Faker::Stripe.invalid_card(card_error: "addressZipFail") #=> "4000000000000010" Faker::Stripe.month #=> "10" @@ -21,14 +21,14 @@ Faker::Stripe.year #=> "2018" # This will always be a year in the future Faker::Stripe.ccv #=> "123" -Faker::Stripe.ccv("amex") #=> "1234" +Faker::Stripe.ccv(card_type: "amex") #=> "1234" ``` ProTip: Use some of the other handy Faker classes for Stripe charge amounts and email. ```ruby -Faker::Number.between(3,10) #=> 100 +Faker::Number.between(from: 3, to: 10) #=> 100 Faker::Internet.free_email #=> "freddy@gmail.com" ``` diff --git a/doc/default/time.md b/doc/default/time.md index a5f283f9dd..97f2c1a865 100644 --- a/doc/default/time.md +++ b/doc/default/time.md @@ -8,17 +8,17 @@ Faker::Time.between(DateTime.now - 1, DateTime.now) #=> "2014-09-18 12:30:59 -07 # You can install the as-duration gem to facilitate time manipulation like 45.minutes + 2.hours # (not needed if you already have activesupport, which is included with Rails) require 'as-duration' -Faker::Time.between(2.days.ago, Date.today, :all) #=> "2014-09-19 07:03:30 -0700" -Faker::Time.between(2.days.ago, Date.today, :day) #=> "2014-09-18 16:28:13 -0700" -Faker::Time.between(2.days.ago, Date.today, :night) #=> "2014-09-20 19:39:38 -0700" -Faker::Time.between(2.days.ago, Date.today, :morning) #=> "2014-09-19 08:07:52 -0700" -Faker::Time.between(2.days.ago, Date.today, :afternoon) #=> "2014-09-18 12:10:34 -0700" -Faker::Time.between(2.days.ago, Date.today, :evening) #=> "2014-09-19 20:21:03 -0700" -Faker::Time.between(2.days.ago, Date.today, :midnight) #=> "2014-09-20 00:40:14 -0700" +Faker::Time.between(2.days.ago, Date.today, period: :all) #=> "2014-09-19 07:03:30 -0700" +Faker::Time.between(2.days.ago, Date.today, period: :day) #=> "2014-09-18 16:28:13 -0700" +Faker::Time.between(2.days.ago, Date.today, period: :night) #=> "2014-09-20 19:39:38 -0700" +Faker::Time.between(2.days.ago, Date.today, period: :morning) #=> "2014-09-19 08:07:52 -0700" +Faker::Time.between(2.days.ago, Date.today, period: :afternoon) #=> "2014-09-18 12:10:34 -0700" +Faker::Time.between(2.days.ago, Date.today, period: :evening) #=> "2014-09-19 20:21:03 -0700" +Faker::Time.between(2.days.ago, Date.today, period: :midnight) #=> "2014-09-20 00:40:14 -0700" # Random time in the future (up to maximum of N days) -Faker::Time.forward(23, :morning) # => "2014-09-26 06:54:47 -0700" +Faker::Time.forward(days: 23, period: :morning) # => "2014-09-26 06:54:47 -0700" # Random time in the past (up to maximum of N days) -Faker::Time.backward(14, :evening) #=> "2014-09-17 19:56:33 -0700" +Faker::Time.backward(days: 14, period: :evening) #=> "2014-09-17 19:56:33 -0700" ``` diff --git a/doc/default/types.md b/doc/default/types.md index 889d370221..ca1045e962 100644 --- a/doc/default/types.md +++ b/doc/default/types.md @@ -12,13 +12,13 @@ Faker::Types.rb_integer #=> 1 # Random Hash (with random keys and values) Faker::Types.rb_hash #=> {name: "bob"} -Faker::Types.rb_hash(1) #=> {name: "bob"} -Faker::Types.rb_hash(2) #=> {name: "bob", last: "marley"} +Faker::Types.rb_hash(key_count: 1) #=> {name: "bob"} +Faker::Types.rb_hash(key_count: 2) #=> {name: "bob", last: "marley"} -# Random Complex Hash (values include other hashes and arrays) +# Random Complex Hash (values include other hashes and arrays) Faker::Types.complex_rb_hash #=> {user: {first: "bob", last: "marley"}} -Faker::Types.complex_rb_hash(1) #=> {user: {first: "bob", last: "marley"}} -Faker::Types.complex_rb_hash(2) #=> {user: {first: "bob", last: "marley"}, son: ["damien", "marley"]} +Faker::Types.complex_rb_hash(key_count: 1) #=> {user: {first: "bob", last: "marley"}} +Faker::Types.complex_rb_hash(key_count: 2) #=> {user: {first: "bob", last: "marley"}, son: ["damien", "marley"]} # Random Array Faker::Types.rb_array #=> ["a", 1, 2, "bob"] diff --git a/doc/default/vehicle.md b/doc/default/vehicle.md index 75284d147c..c64506a299 100644 --- a/doc/default/vehicle.md +++ b/doc/default/vehicle.md @@ -11,7 +11,7 @@ Faker::Vehicle.make #=> "Honda" # Random vehicle model Faker::Vehicle.model #=> "A8" -Faker::Vehicle.model('Toyota') #=> "Prius" +Faker::Vehicle.model(make_of_model: 'Toyota') #=> "Prius" Faker::Vehicle.make_and_model #=> "Dodge Charger" # Random vehicle color @@ -52,13 +52,13 @@ Faker::Vehicle.year #=> 2008 # Random mileage/kilometrage Faker::Vehicle.mileage #=> 26961 -Faker::Vehicle.mileage(50_000) #=> 81557 -Faker::Vehicle.mileage(50_000, 250_000) #=> 117503 +Faker::Vehicle.mileage(min: 50_000) #=> 81557 +Faker::Vehicle.mileage(min: 50_000, max: 250_000) #=> 117503 Faker::Vehicle.kilometrage #=> 35378 # Random vehicle license plate (USA by default) Faker::Vehicle.license_plate #=> "DEP-2483" -Faker::Vehicle.license_plate('FL') #=> "977 UNU" +Faker::Vehicle.license_plate(state_abreviation: 'FL') #=> "977 UNU" # Random vehicle license plate for Singapore (if locale is set) Faker::Vehicle.singapore_license_plate #=> "SLV1854M" diff --git a/doc/default/world_cup.md b/doc/default/world_cup.md index f949b8a711..5086120136 100644 --- a/doc/default/world_cup.md +++ b/doc/default/world_cup.md @@ -11,9 +11,9 @@ Faker::WorldCup.city #=> "Saint Petersburg" Faker::WorldCup.group #=> "Egypt" -Faker::WorldCup.group('group_A') #=> "Saudi Arabia" +Faker::WorldCup.group(group: 'group_A') #=> "Saudi Arabia" Faker::WorldCup.roster #=> "Héctor Cúper" -Faker::WorldCup.roster('Russia', 'coach') #=> "Stanislav Cherchesov" +Faker::WorldCup.roster(country: 'Russia', type: 'coach') #=> "Stanislav Cherchesov" ``` diff --git a/doc/movies/star_wars.md b/doc/movies/star_wars.md index dd60d8548b..8210234af9 100644 --- a/doc/movies/star_wars.md +++ b/doc/movies/star_wars.md @@ -17,7 +17,7 @@ Faker::Movies::StarWars.planet #=> "Tatooine" Faker::Movies::StarWars.quote #=> "Aren’t you a little short for a Stormtrooper?" -Faker::Movies::StarWars.quote("leia_organa") #=> "Aren’t you a little short for a Stormtrooper?" +Faker::Movies::StarWars.quote(character: "leia_organa") #=> "Aren’t you a little short for a Stormtrooper?" Faker::Movies::StarWars.specie #=> "Gungan" diff --git a/lib/faker/books/dune.rb b/lib/faker/books/dune.rb index 774012b29c..4500bb5dc8 100644 --- a/lib/faker/books/dune.rb +++ b/lib/faker/books/dune.rb @@ -19,7 +19,7 @@ def planet fetch('dune.planets') end - def quote(character = nil) + def quote(character: nil) quoted_characters = translate('faker.dune.quotes').keys if character.nil? @@ -36,7 +36,7 @@ def quote(character = nil) fetch('dune.quotes.' + character) end - def saying(source = nil) + def saying(source: nil) sourced_sayings = translate('faker.dune.sayings').keys if source.nil? diff --git a/lib/faker/books/lovecraft.rb b/lib/faker/books/lovecraft.rb index 43c9871bc5..162b0b0326 100644 --- a/lib/faker/books/lovecraft.rb +++ b/lib/faker/books/lovecraft.rb @@ -8,7 +8,7 @@ def location fetch('lovecraft.location') end - def fhtagn(number_of = 1) + def fhtagn(number_of: 1) Array.new(number_of) { fetch('lovecraft.fhtagn') }.join('. ') end @@ -20,8 +20,8 @@ def tome fetch('lovecraft.tome') end - def sentence(word_count = 4, random_words_to_add = 6) - words(word_count + rand(random_words_to_add.to_i).to_i, true).join(' ').capitalize + '.' + def sentence(word_count: 4, random_words_to_add: 6) + words(num: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: true).join(' ').capitalize + '.' end def word @@ -29,7 +29,7 @@ def word random_word =~ /\s/ ? word : random_word end - def words(num = 3, spaces_allowed = false) + def words(num: 3, spaces_allowed: false) resolved_num = resolve(num) word_list = translate('faker.lovecraft.words') word_list *= ((resolved_num / word_list.length) + 1) @@ -40,30 +40,30 @@ def words(num = 3, spaces_allowed = false) words.each_with_index { |w, i| words[i] = word if w =~ /\s/ } end - def sentences(sentence_count = 3) + def sentences(sentence_count: 3) [].tap do |sentences| 1.upto(resolve(sentence_count)) do - sentences << sentence(3) + sentences << sentence(word_count: 3) end end end - def paragraph(sentence_count = 3, random_sentences_to_add = 3) - sentences(resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ') + def paragraph(sentence_count: 3, random_sentences_to_add: 3) + sentences(sentence_count: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ') end - def paragraphs(paragraph_count = 3) + def paragraphs(paragraph_count: 3) [].tap do |paragraphs| 1.upto(resolve(paragraph_count)) do - paragraphs << paragraph(3) + paragraphs << paragraph(sentence_count: 3) end end end - def paragraph_by_chars(chars = 256) - paragraph = paragraph(3) + def paragraph_by_chars(chars: 256) + paragraph = paragraph(sentence_count: 3) - paragraph += ' ' + paragraph(3) while paragraph.length < chars + paragraph += ' ' + paragraph(sentence_count: 3) while paragraph.length < chars paragraph[0...chars - 1] + '.' end diff --git a/lib/faker/default/address.rb b/lib/faker/default/address.rb index e1cfbc17d0..3ba84c3327 100644 --- a/lib/faker/default/address.rb +++ b/lib/faker/default/address.rb @@ -5,7 +5,7 @@ class Address < Base flexible :address class << self - def city(options = {}) + def city(options: {}) parse(options[:with_state] ? 'address.city_with_state' : 'address.city') end @@ -13,7 +13,7 @@ def street_name parse('address.street_name') end - def street_address(include_secondary = false) + def street_address(include_secondary: false) numerify(parse('address.street_address') + (include_secondary ? ' ' + secondary_address : '')) end @@ -29,7 +29,7 @@ def community parse('address.community') end - def zip_code(state_abbreviation = '') + def zip_code(state_abbreviation: '') if state_abbreviation.empty? letterified_string = letterify(fetch('address.postcode')) return numerify(letterified_string, leading_zero: true) diff --git a/lib/faker/default/alphanumeric.rb b/lib/faker/default/alphanumeric.rb index 5d190a5cd9..eac4b45174 100644 --- a/lib/faker/default/alphanumeric.rb +++ b/lib/faker/default/alphanumeric.rb @@ -6,14 +6,14 @@ class << self ALPHABET = ('a'..'z').to_a ALPHANUMS = ALPHABET + (0..9).to_a - def alpha(char_count = 32) + def alpha(char_count: 32) char_count = resolve(char_count) return '' if char_count.to_i < 1 Array.new(char_count) { sample(ALPHABET) }.join end - def alphanumeric(char_count = 32) + def alphanumeric(char_count: 32) char_count = resolve(char_count) return '' if char_count.to_i < 1 diff --git a/lib/faker/default/avatar.rb b/lib/faker/default/avatar.rb index 8c3f27982f..a22998d36f 100644 --- a/lib/faker/default/avatar.rb +++ b/lib/faker/default/avatar.rb @@ -5,7 +5,7 @@ class Avatar < Base class << self SUPPORTED_FORMATS = %w[png jpg bmp].freeze - def image(slug = nil, size = '300x300', format = 'png', set = 'set1', bgset = nil) + def image(slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil) raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format) diff --git a/lib/faker/default/bank.rb b/lib/faker/default/bank.rb index a41fafa89a..029a41e12e 100644 --- a/lib/faker/default/bank.rb +++ b/lib/faker/default/bank.rb @@ -5,7 +5,7 @@ class Bank < Base flexible :bank class << self - def account_number(digits = 10) + def account_number(digits: 10) output = '' output += rand.to_s[2..-1] while output.length < digits @@ -13,7 +13,7 @@ def account_number(digits = 10) output[0...digits] end - def iban(country_code = 'GB') + def iban(country_code: 'GB') # Each country has it's own format for bank accounts # Many of them use letters in certain parts of the account # Using regex patterns we can create virtually any type of bank account diff --git a/lib/faker/default/boolean.rb b/lib/faker/default/boolean.rb index cd7912f153..e1acb921ff 100644 --- a/lib/faker/default/boolean.rb +++ b/lib/faker/default/boolean.rb @@ -3,7 +3,7 @@ module Faker class Boolean < Base class << self - def boolean(true_ratio = 0.5) + def boolean(true_ratio: 0.5) (rand < true_ratio) end end diff --git a/lib/faker/default/chile_rut.rb b/lib/faker/default/chile_rut.rb index d8f6eccd1b..047d3f888e 100644 --- a/lib/faker/default/chile_rut.rb +++ b/lib/faker/default/chile_rut.rb @@ -6,7 +6,7 @@ class << self @last_rut = nil # Fixed param added for testing a specific RUT and check digit combination. - def rut(min_rut = 1, fixed = false) + def rut(min_rut: 1, fixed: false) @last_rut = fixed ? min_rut : rand_in_range(min_rut, 99_999_999) end @@ -34,8 +34,8 @@ def check_digit dv end - def full_rut(min_rut = 0, fixed = false) - "#{rut(min_rut, fixed)}-#{dv}" + def full_rut(min_rut: 0, fixed: false) + "#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}" end attr_reader :last_rut diff --git a/lib/faker/default/code.rb b/lib/faker/default/code.rb index 2c73bca6ac..73bd19519f 100644 --- a/lib/faker/default/code.rb +++ b/lib/faker/default/code.rb @@ -12,26 +12,26 @@ def npi # By default generates 10 sign isbn code in format 123456789-X # You can pass 13 to generate new 13 sign code - def isbn(base = 10) + def isbn(base: 10) base == 13 ? generate_base13_isbn : generate_base10_isbn end # By default generates 13 sign ean code in format 1234567890123 # You can pass 8 to generate ean8 code - def ean(base = 13) + def ean(base: 13) base == 8 ? generate_base8_ean : generate_base13_ean end def rut - value = Number.number(8).to_s + value = Number.number(digits: 8).to_s vd = rut_verificator_digit(value) value << "-#{vd}" end # By default generates a Singaporean NRIC ID for someone # who is born between the age of 18 and 65. - def nric(min_age = 18, max_age = 65) - birthyear = Date.birthday(min_age, max_age).year + def nric(min_age: 18, max_age: 65) + birthyear = Date.birthday(min_age: min_age, max_age: max_age).year prefix = birthyear < 2000 ? 'S' : 'T' values = birthyear.to_s[-2..-1] values << regexify(/\d{5}/) diff --git a/lib/faker/default/commerce.rb b/lib/faker/default/commerce.rb index 933202290f..0fb6e41943 100644 --- a/lib/faker/default/commerce.rb +++ b/lib/faker/default/commerce.rb @@ -7,15 +7,15 @@ def color fetch('color.name') end - def promotion_code(digits = 6) + def promotion_code(digits: 6) [ fetch('commerce.promotion_code.adjective'), fetch('commerce.promotion_code.noun'), - Faker::Number.number(digits) + Faker::Number.number(digits: digits) ].join end - def department(max = 3, fixed_amount = false) + def department(max: 3, fixed_amount: false) num = max if fixed_amount num ||= 1 + rand(max) diff --git a/lib/faker/default/company.rb b/lib/faker/default/company.rb index 594e654fcd..e787a60641 100644 --- a/lib/faker/default/company.rb +++ b/lib/faker/default/company.rb @@ -126,7 +126,7 @@ def polish_taxpayer_identification_number end # Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON - def polish_register_of_national_economy(length = 9) + def polish_register_of_national_economy(length: 9) raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length random_digits = [] diff --git a/lib/faker/default/crypto_coin.rb b/lib/faker/default/crypto_coin.rb index e323882831..7d9bd17443 100644 --- a/lib/faker/default/crypto_coin.rb +++ b/lib/faker/default/crypto_coin.rb @@ -7,15 +7,15 @@ class << self ACRONYM = 1 URL_LOGO = 2 - def coin_name(coin = coin_array) + def coin_name(coin: coin_array) coin[COIN_NAME] end - def acronym(coin = coin_array) + def acronym(coin: coin_array) coin[ACRONYM] end - def url_logo(coin = coin_array) + def url_logo(coin: coin_array) coin[URL_LOGO] end @@ -25,7 +25,12 @@ def coin_array def coin_hash coin = coin_array - { name: coin_name(coin), acronym: acronym(coin), url_logo: url_logo(coin) } + + { + name: coin_name(coin: coin), + acronym: acronym(coin: coin), + url_logo: url_logo(coin: coin) + } end end end diff --git a/lib/faker/default/date.rb b/lib/faker/default/date.rb index ecb3be383d..32233ea981 100644 --- a/lib/faker/default/date.rb +++ b/lib/faker/default/date.rb @@ -21,21 +21,21 @@ def between_except(from, to, excepted) end end - def forward(days = 365) + def forward(days: 365) from = ::Date.today + 1 to = ::Date.today + days between(from, to).to_date end - def backward(days = 365) + def backward(days: 365) from = ::Date.today - days to = ::Date.today - 1 between(from, to).to_date end - def birthday(min_age = 18, max_age = 65) + def birthday(min_age: 18, max_age: 65) t = ::Date.today from = birthday_date(t, max_age) diff --git a/lib/faker/default/demographic.rb b/lib/faker/default/demographic.rb index bb51caff85..ea6d867f17 100644 --- a/lib/faker/default/demographic.rb +++ b/lib/faker/default/demographic.rb @@ -23,7 +23,7 @@ def sex fetch('demographic.sex') end - def height(unit = :metric) + def height(unit: :metric) case unit when :imperial inches = rand_in_range(57, 86) diff --git a/lib/faker/default/device.rb b/lib/faker/default/device.rb index ffa2af1b35..04412daafe 100644 --- a/lib/faker/default/device.rb +++ b/lib/faker/default/device.rb @@ -4,7 +4,7 @@ module Faker class Device < Base class << self def build_number - Faker::Number.between(1, 500) + Faker::Number.between(from: 1, to: 500) end def manufacturer @@ -24,7 +24,7 @@ def serial end def version - Faker::Number.between(1, 1000) + Faker::Number.between(from: 1, to: 1000) end end end diff --git a/lib/faker/default/driving_licence.rb b/lib/faker/default/driving_licence.rb index 6ea089bbf8..00c6b65779 100644 --- a/lib/faker/default/driving_licence.rb +++ b/lib/faker/default/driving_licence.rb @@ -9,7 +9,7 @@ class << self def british_driving_licence(last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, - date_of_birth: Faker::Date.birthday(18, 65)) + date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65)) [ gb_licence_padding(last_name, 5), gb_licence_year(date_of_birth, gender), @@ -19,7 +19,7 @@ def british_driving_licence(last_name: Faker::Name.last_name, end def northern_irish_driving_licence - Faker::Number.number(8).to_s + Faker::Number.number(digits: 8).to_s end def uk_driving_licence(*args) diff --git a/lib/faker/default/file.rb b/lib/faker/default/file.rb index 44fa8ec0d0..998c4f3bb5 100644 --- a/lib/faker/default/file.rb +++ b/lib/faker/default/file.rb @@ -3,7 +3,7 @@ module Faker class File < Base class << self - def dir(segment_count = 3, root = nil, directory_separator = '/') + def dir(segment_count: 3, root: nil, directory_separator: '/') Array .new(segment_count) { Faker::Internet.slug } .unshift(root) @@ -20,8 +20,8 @@ def mime_type fetch('file.mime_type') end - def file_name(dir = nil, name = nil, ext = nil, directory_separator = '/') - dir ||= dir(1) + def file_name(dir: nil, name: nil, ext: nil, directory_separator: '/') + dir ||= dir(segment_count: 1) name ||= Faker::Lorem.word.downcase ext ||= extension diff --git a/lib/faker/default/fillmurray.rb b/lib/faker/default/fillmurray.rb index 2d8172f97d..143d9c9260 100644 --- a/lib/faker/default/fillmurray.rb +++ b/lib/faker/default/fillmurray.rb @@ -3,7 +3,7 @@ module Faker class Fillmurray < Base class << self - def image(grayscale = false, width = 200, height = 200) + def image(grayscale: false, width: 200, height: 200) raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/ raise ArgumentError, 'Height should be a number' unless height.to_s =~ /^\d+$/ raise ArgumentError, 'Grayscale should be a boolean' unless [true, false].include?(grayscale) diff --git a/lib/faker/default/finance.rb b/lib/faker/default/finance.rb index c558816b16..fdfad99245 100644 --- a/lib/faker/default/finance.rb +++ b/lib/faker/default/finance.rb @@ -26,7 +26,7 @@ def credit_card(*types) template.gsub('L', luhn_digit.to_s) end - def vat_number(country = 'BR') + def vat_number(country: 'BR') numerify(fetch("finance.vat_number.#{country}")) rescue I18n::MissingTranslationData raise ArgumentError, "Could not find vat number for #{country}" diff --git a/lib/faker/default/hipster.rb b/lib/faker/default/hipster.rb index dc86e1a510..d476a027aa 100644 --- a/lib/faker/default/hipster.rb +++ b/lib/faker/default/hipster.rb @@ -8,7 +8,7 @@ def word random_word =~ /\s/ ? word : random_word end - def words(num = 3, supplemental = false, spaces_allowed = false) + def words(num: 3, supplemental: false, spaces_allowed: false) resolved_num = resolve(num) word_list = ( translate('faker.hipster.words') + @@ -22,34 +22,34 @@ def words(num = 3, supplemental = false, spaces_allowed = false) words.each_with_index { |w, i| words[i] = word if w =~ /\s/ } end - def sentence(word_count = 4, supplemental = false, random_words_to_add = 6) - words(word_count + rand(random_words_to_add.to_i).to_i, supplemental, true).join(' ').capitalize + '.' + def sentence(word_count: 4, supplemental: false, random_words_to_add: 6) + words(num: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.' end - def sentences(sentence_count = 3, supplemental = false) + def sentences(sentence_count: 3, supplemental: false) [].tap do |sentences| 1.upto(resolve(sentence_count)) do - sentences << sentence(3, supplemental) + sentences << sentence(word_count: 3, supplemental: supplemental) end end end - def paragraph(sentence_count = 3, supplemental = false, random_sentences_to_add = 3) - sentences(resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental).join(' ') + def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3) + sentences(sentence_count: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ') end - def paragraphs(paragraph_count = 3, supplemental = false) + def paragraphs(paragraph_count: 3, supplemental: false) [].tap do |paragraphs| 1.upto(resolve(paragraph_count)) do - paragraphs << paragraph(3, supplemental) + paragraphs << paragraph(sentence_count: 3, supplemental: supplemental) end end end - def paragraph_by_chars(chars = 256, supplemental = false) - paragraph = paragraph(3, supplemental) + def paragraph_by_chars(chars: 256, supplemental: false) + paragraph = paragraph(sentence_count: 3, supplemental: supplemental) - paragraph += ' ' + paragraph(3, supplemental) while paragraph.length < chars + paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < chars paragraph[0...chars - 1] + '.' end diff --git a/lib/faker/default/id_number.rb b/lib/faker/default/id_number.rb index e923012a04..cf424a8192 100644 --- a/lib/faker/default/id_number.rb +++ b/lib/faker/default/id_number.rb @@ -29,7 +29,7 @@ def ssn_valid end def spanish_citizen_number - num = Faker::Number.number(8) + num = Faker::Number.number(digits: 8) mod = num.to_i % 23 check = CHECKS[mod] "#{num}-#{check}" @@ -37,7 +37,7 @@ def spanish_citizen_number def spanish_foreign_citizen_number code = 'XYZ' - digits = Faker::Number.number(7) + digits = Faker::Number.number(digits: 7) prefix = code[rand(code.length)] prefix_val = 'XYZ'.index(prefix).to_s mod = "#{prefix_val}#{digits}".to_i % 23 @@ -48,7 +48,7 @@ def spanish_foreign_citizen_number def valid_south_african_id_number id_number = [ Faker::Date.birthday.strftime('%y%m%d'), - Faker::Number.number(4), + Faker::Number.number(digits: 4), ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random), ZA_RACE_DIGIT ].join @@ -60,14 +60,14 @@ def valid_south_african_id_number def invalid_south_african_id_number invalid_date_of_birth = [ - Faker::Number.number(2), - Faker::Number.between(13, 99), - Faker::Number.between(32, 99) + Faker::Number.number(digits: 2), + Faker::Number.between(from: 13, to: 99), + Faker::Number.between(from: 32, to: 99) ].map(&:to_s).join id_number = [ invalid_date_of_birth, - Faker::Number.number(4), + Faker::Number.number(digits: 4), ZA_CITIZENSHIP_DIGITS.sample(random: Faker::Config.random), ZA_RACE_DIGIT ].join @@ -76,7 +76,7 @@ def invalid_south_african_id_number end def brazilian_citizen_number(formatted: false) - digits = Faker::Number.number(9).to_s until digits&.match(/(\d)((?!\1)\d)+/) + digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/) first_digit = brazilian_citizen_number_checksum_digit(digits) second_digit = brazilian_citizen_number_checksum_digit(digits + first_digit) number = [digits, first_digit, second_digit].join diff --git a/lib/faker/default/internet.rb b/lib/faker/default/internet.rb index 09447f67fa..a6c0f4549d 100644 --- a/lib/faker/default/internet.rb +++ b/lib/faker/default/internet.rb @@ -5,21 +5,21 @@ class Internet < Base class << self def email(name = nil, *separators) if separators - [username(name, separators), domain_name].join('@') + [username(specifier: name, separators: separators), domain_name].join('@') else - [username(name), domain_name].join('@') + [username(specifier: name), domain_name].join('@') end end - def free_email(name = nil) - [username(name), fetch('internet.free_email')].join('@') + def free_email(name: nil) + [username(specifier: name), fetch('internet.free_email')].join('@') end - def safe_email(name = nil) - [username(name), 'example.' + sample(%w[org com net])].join('@') + def safe_email(name: nil) + [username(specifier: name), 'example.' + sample(%w[org com net])].join('@') end - def username(specifier = nil, separators = %w[. _]) + def username(specifier: nil, separators: %w[. _]) with_locale(:en) do return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan) @@ -30,7 +30,7 @@ def username(specifier = nil, separators = %w[. _]) tries = 0 # Don't try forever in case we get something like 1_000_000. result = nil loop do - result = username(nil, separators) + result = username(specifier: nil, separators: separators) tries += 1 break unless result.length < specifier && tries < 7 end @@ -39,7 +39,7 @@ def username(specifier = nil, separators = %w[. _]) tries = 0 result = nil loop do - result = username(specifier.min, separators) + result = username(specifier: specifier.min, separators: separators) tries += 1 break unless !specifier.include?(result.length) && tries < 7 end @@ -55,12 +55,12 @@ def username(specifier = nil, separators = %w[. _]) end end - def password(min_length = 8, max_length = 16, mix_case = true, special_chars = false) - temp = Lorem.characters(min_length) + def password(min_length: 8, max_length: 16, mix_case: true, special_chars: false) + temp = Lorem.characters(char_count: min_length) diff_length = max_length - min_length if diff_length.positive? diff_rand = rand(diff_length + 1) - temp += Lorem.characters(diff_rand) + temp += Lorem.characters(char_count: diff_rand) end if mix_case @@ -79,7 +79,7 @@ def password(min_length = 8, max_length = 16, mix_case = true, special_chars = f temp end - def domain_name(subdomain = false) + def domain_name(subdomain: false) with_locale(:en) do domain_elements = [Char.prepare(domain_word), domain_suffix] domain_elements.unshift(Char.prepare(domain_word)) if subdomain @@ -87,7 +87,7 @@ def domain_name(subdomain = false) end end - def fix_umlauts(string = '') + def fix_umlauts(string: '') Char.fix_umlauts(string) end @@ -99,7 +99,7 @@ def domain_suffix fetch('internet.domain_suffix') end - def mac_address(prefix = '') + def mac_address(prefix: '') prefix_digits = prefix.split(':').map { |d| d.to_i(16) } address_digits = Array.new((6 - prefix_digits.size)) { rand(256) } (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':') @@ -173,20 +173,20 @@ def ip_v6_cidr "#{ip_v6_address}/#{rand(1..127)}" end - def url(host = domain_name, path = "/#{username}", scheme = 'http') + def url(host: domain_name, path: "/#{username}", scheme: 'http') "#{scheme}://#{host}#{path}" end - def slug(words = nil, glue = nil) + def slug(words: nil, glue: nil) glue ||= sample(%w[- _]) - (words || Faker::Lorem.words(2).join(' ')).delete(',.').gsub(' ', glue).downcase + (words || Faker::Lorem.words(num: 2).join(' ')).delete(',.').gsub(' ', glue).downcase end def device_token shuffle(rand(16**64).to_s(16).rjust(64, '0').chars.to_a).join end - def user_agent(vendor = nil) + def user_agent(vendor: nil) agent_hash = translate('faker.internet.user_agent') agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)] sample(agents) diff --git a/lib/faker/default/invoice.rb b/lib/faker/default/invoice.rb index 35e74fec9e..20404ae36d 100644 --- a/lib/faker/default/invoice.rb +++ b/lib/faker/default/invoice.rb @@ -6,13 +6,13 @@ class Invoice < Base class << self # Generate random amount between values with 2 decimals - def amount_between(from = 0, to = 0) + def amount_between(from: 0, to: 0) Faker::Base.rand_in_range(from, to).round(2) end # International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference # ref is optional so that we can create unit tests - def creditor_reference(ref = '') + def creditor_reference(ref: '') ref = reference if ref.empty? 'RF' + iban_checksum('RF', ref) + ref @@ -20,7 +20,7 @@ def creditor_reference(ref = '') # Payment references have some rules in certain countries # ref is optional so that we can create unit tests - def reference(ref = '') + def reference(ref: '') pattern = fetch('invoice.reference.pattern') ref = Base.regexify(/#{pattern}/) if ref.empty? diff --git a/lib/faker/default/json.rb b/lib/faker/default/json.rb index 98fca34e71..d6d67eaaec 100644 --- a/lib/faker/default/json.rb +++ b/lib/faker/default/json.rb @@ -3,7 +3,7 @@ class Json < Base require 'json' class << self - def shallow_json(width = 3, options = { key: 'Name.first_name', value: 'Name.first_name' }) + def shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) options[:key] = 'Faker::' + options[:key] options[:value] = 'Faker::' + options[:value] @@ -11,7 +11,7 @@ def shallow_json(width = 3, options = { key: 'Name.first_name', value: 'Name.fir JSON.generate(hash) end - def add_depth_to_json(json = shallow_json, width = 3, options = { key: 'Name.first_name', value: 'Name.first_name' }) + def add_depth_to_json(json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) options[:key] = 'Faker::' + options[:key] options[:value] = 'Faker::' + options[:value] diff --git a/lib/faker/default/lorem.rb b/lib/faker/default/lorem.rb index 097f3a739c..1d8473bac4 100644 --- a/lib/faker/default/lorem.rb +++ b/lib/faker/default/lorem.rb @@ -8,7 +8,7 @@ def word sample(translate('faker.lorem.words')) end - def words(num = 3, supplemental = false) + def words(num: 3, supplemental: false) resolved_num = resolve(num) word_list = ( translate('faker.lorem.words') + @@ -22,44 +22,44 @@ def character sample(Types::CHARACTERS) end - def characters(char_count = 255) - Alphanumeric.alphanumeric(char_count) + def characters(char_count: 255) + Alphanumeric.alphanumeric(char_count: char_count) end def multibyte sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8') end - def sentence(word_count = 4, supplemental = false, random_words_to_add = 0) - words(word_count + rand(random_words_to_add.to_i), supplemental).join(' ').capitalize + locale_period + def sentence(word_count: 4, supplemental: false, random_words_to_add: 0) + words(num: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(' ').capitalize + locale_period end - def sentences(sentence_count = 3, supplemental = false) - 1.upto(resolve(sentence_count)).collect { sentence(3, supplemental) } + def sentences(sentence_count: 3, supplemental: false) + 1.upto(resolve(sentence_count)).collect { sentence(word_count: 3, supplemental: supplemental) } end - def paragraph(sentence_count = 3, supplemental = false, random_sentences_to_add = 0) - sentences(resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental).join(locale_space) + def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0) + sentences(sentence_count: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space) end - def paragraphs(paragraph_count = 3, supplemental = false) - 1.upto(resolve(paragraph_count)).collect { paragraph(3, supplemental) } + def paragraphs(paragraph_count: 3, supplemental: false) + 1.upto(resolve(paragraph_count)).collect { paragraph(sentence_count: 3, supplemental: supplemental) } end - def paragraph_by_chars(chars = 256, supplemental = false) - paragraph = paragraph(3, supplemental) + def paragraph_by_chars(chars: 256, supplemental: false) + paragraph = paragraph(sentence_count: 3, supplemental: supplemental) - paragraph += ' ' + paragraph(3, supplemental) while paragraph.length < chars + paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < chars paragraph[0...chars - 1] + '.' end - def question(word_count = 4, supplemental = false, random_words_to_add = 0) - words(word_count + rand(random_words_to_add), supplemental).join(' ').capitalize + locale_question_mark + def question(word_count: 4, supplemental: false, random_words_to_add: 0) + words(num: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark end - def questions(question_count = 3, supplemental = false) - 1.upto(resolve(question_count)).collect { question(3, supplemental) } + def questions(question_count: 3, supplemental: false) + 1.upto(resolve(question_count)).collect { question(word_count: 3, supplemental: supplemental) } end private diff --git a/lib/faker/default/lorem_flickr.rb b/lib/faker/default/lorem_flickr.rb index c4658012fe..ba0eb02882 100644 --- a/lib/faker/default/lorem_flickr.rb +++ b/lib/faker/default/lorem_flickr.rb @@ -5,23 +5,23 @@ class LoremFlickr < Base class << self SUPPORTED_COLORIZATIONS = %w[red green blue].freeze - def image(size = '300x300', search_terms = [], match_all = false) + def image(size: '300x300', search_terms: [], match_all: false) build_url(size, nil, search_terms, match_all) end - def grayscale_image(size = '300x300', search_terms = ['all'], match_all = false) + def grayscale_image(size: '300x300', search_terms: ['all'], match_all: false) raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any? build_url(size, 'g', search_terms, match_all) end - def pixelated_image(size = '300x300', search_terms = ['all'], match_all = false) + def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false) raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any? build_url(size, 'p', search_terms, match_all) end - def colorized_image(size = '300x300', color = 'red', search_terms = ['all'], match_all = false) + def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false) raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any? raise ArgumentError, "Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}" unless SUPPORTED_COLORIZATIONS.include?(color) diff --git a/lib/faker/default/lorem_pixel.rb b/lib/faker/default/lorem_pixel.rb index 9fbf007528..f07f00794d 100644 --- a/lib/faker/default/lorem_pixel.rb +++ b/lib/faker/default/lorem_pixel.rb @@ -18,7 +18,7 @@ class << self transport].freeze # rubocop:disable Metrics/ParameterLists - def image(size = '300x300', is_gray = false, category = nil, number = nil, text = nil, secure: true) + def image(size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true) raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ raise ArgumentError, "Supported categories are #{SUPPORTED_CATEGORIES.join(', ')}" unless category.nil? || SUPPORTED_CATEGORIES.include?(category) raise ArgumentError, 'Category required when number is passed' if !number.nil? && category.nil? diff --git a/lib/faker/default/markdown.rb b/lib/faker/default/markdown.rb index 7b408fe5b7..e18b0f8350 100644 --- a/lib/faker/default/markdown.rb +++ b/lib/faker/default/markdown.rb @@ -8,7 +8,7 @@ def headers end def emphasis - paragraph = Faker::Lorem.paragraph(3) + paragraph = Faker::Lorem.paragraph(sentence_count: 3) words = paragraph.split(' ') position = rand(0..words.length - 1) formatting = fetch('markdown.emphasis') @@ -21,7 +21,7 @@ def ordered_list result = [] number.times do |i| - result << "#{i}. #{Faker::Lorem.sentence(1)} \n" + result << "#{i}. #{Faker::Lorem.sentence(word_count: 1)} \n" end result.join('') end @@ -31,17 +31,17 @@ def unordered_list result = [] number.times do |_i| - result << "* #{Faker::Lorem.sentence(1)} \n" + result << "* #{Faker::Lorem.sentence(word_count: 1)} \n" end result.join('') end def inline_code - "`#{Faker::Lorem.sentence(1)}`" + "`#{Faker::Lorem.sentence(word_count: 1)}`" end def block_code - "```ruby\n#{Lorem.sentence(1)}\n```" + "```ruby\n#{Lorem.sentence(word_count: 1)}\n```" end def table @@ -59,11 +59,11 @@ def random(*args) send(method_list[rand(0..method_list.length - 1)]) end - def sandwich(sentences = 3, repeat = 1) + def sandwich(sentences: 3, repeat: 1) text_block = [] text_block << headers repeat.times do - text_block << Faker::Lorem.paragraph(sentences) + text_block << Faker::Lorem.paragraph(sentence_count: sentences) text_block << random end text_block.join("\n") diff --git a/lib/faker/default/measurement.rb b/lib/faker/default/measurement.rb index 0506f94a8b..2c9703c9e0 100644 --- a/lib/faker/default/measurement.rb +++ b/lib/faker/default/measurement.rb @@ -6,35 +6,35 @@ class << self ALL = 'all' NONE = 'none' - def height(amount = rand(10)) + def height(amount: rand(10)) define_measurement_locale(amount, 'height') end - def length(amount = rand(10)) + def length(amount: rand(10)) define_measurement_locale(amount, 'length') end - def volume(amount = rand(10)) + def volume(amount: rand(10)) define_measurement_locale(amount, 'volume') end - def weight(amount = rand(10)) + def weight(amount: rand(10)) define_measurement_locale(amount, 'weight') end - def metric_height(amount = rand(10)) + def metric_height(amount: rand(10)) define_measurement_locale(amount, 'metric_height') end - def metric_length(amount = rand(10)) + def metric_length(amount: rand(10)) define_measurement_locale(amount, 'metric_length') end - def metric_volume(amount = rand(10)) + def metric_volume(amount: rand(10)) define_measurement_locale(amount, 'metric_volume') end - def metric_weight(amount = rand(10)) + def metric_weight(amount: rand(10)) define_measurement_locale(amount, 'metric_weight') end diff --git a/lib/faker/default/name.rb b/lib/faker/default/name.rb index 858594fa71..cf17ac55ad 100644 --- a/lib/faker/default/name.rb +++ b/lib/faker/default/name.rb @@ -46,7 +46,7 @@ def suffix fetch('name.suffix') end - def initials(character_count = 3) + def initials(character_count: 3) (0...character_count).map { rand(65..90).chr }.join end end diff --git a/lib/faker/default/nhs.rb b/lib/faker/default/nhs.rb index b6a7be7828..852977d888 100644 --- a/lib/faker/default/nhs.rb +++ b/lib/faker/default/nhs.rb @@ -7,15 +7,15 @@ def british_number base_number = rand(400_000_001...499_999_999) # If the check digit is equivalent to 10, the number is invalid. # See https://en.wikipedia.org/wiki/NHS_number - base_number -= 1 if check_digit(base_number) == 10 - "#{base_number}#{check_digit(base_number)}".to_s - .chars - .insert(3, ' ') - .insert(7, ' ') - .join('') + base_number -= 1 if check_digit(number: base_number) == 10 + "#{base_number}#{check_digit(number: base_number)}".to_s + .chars + .insert(3, ' ') + .insert(7, ' ') + .join('') end - def check_digit(number = 0) + def check_digit(number: 0) sum = 0 number.to_s.chars.each_with_index do |digit, idx| position = idx + 1 diff --git a/lib/faker/default/number.rb b/lib/faker/default/number.rb index 1d1532145a..e745fea215 100644 --- a/lib/faker/default/number.rb +++ b/lib/faker/default/number.rb @@ -3,7 +3,7 @@ module Faker class Number < Base class << self - def number(digits = 10) + def number(digits: 10) return if digits < 1 return 0 if digits == 1 @@ -11,21 +11,21 @@ def number(digits = 10) ([non_zero_digit] + generate(digits - 1)).join.to_i end - def leading_zero_number(digits = 10) + def leading_zero_number(digits: 10) '0' + (2..digits).collect { digit }.join end - def decimal_part(digits = 10) + def decimal_part(digits: 10) num = '' if digits > 1 num = non_zero_digit digits -= 1 end - leading_zero_number(digits) + num.to_s + leading_zero_number(digits: digits) + num.to_s end - def decimal(l_digits = 5, r_digits = 2) - l_d = number(l_digits).to_s + def decimal(l_digits: 5, r_digits: 2) + l_d = number(digits: l_digits) r_d = if r_digits == 1 0 else @@ -44,35 +44,35 @@ def digit rand(10) end - def hexadecimal(digits = 6) + def hexadecimal(digits: 6) hex = '' digits.times { hex += rand(15).to_s(16) } hex end - def normal(mean = 1, standard_deviation = 1) + def normal(mean: 1, standard_deviation: 1) theta = 2 * Math::PI * rand rho = Math.sqrt(-2 * Math.log(1 - rand)) scale = standard_deviation * rho mean + scale * Math.cos(theta) end - def between(from = 1.00, to = 5000.00) + def between(from: 1.00, to: 5000.00) Faker::Base.rand_in_range(from, to) end - def within(range = 1.00..5000.00) - between(range.min, range.max) + def within(range: 1.00..5000.00) + between(from: range.min, to: range.max) end - def positive(from = 1.00, to = 5000.00) - random_number = between(from, to) + def positive(from: 1.00, to: 5000.00) + random_number = between(from: from, to: to) greater_than_zero(random_number) end - def negative(from = -5000.00, to = -1.00) - random_number = between(from, to) + def negative(from: -5000.00, to: -1.00) + random_number = between(from: from, to: to) less_than_zero(random_number) end diff --git a/lib/faker/default/omniauth.rb b/lib/faker/default/omniauth.rb index d7e0fbfb2a..fa3916f49c 100644 --- a/lib/faker/default/omniauth.rb +++ b/lib/faker/default/omniauth.rb @@ -10,12 +10,12 @@ class Omniauth < Base def initialize(name: nil, email: nil) @name = name || "#{Name.first_name} #{Name.last_name}" - @email = email || Internet.safe_email(self.name) + @email = email || Internet.safe_email(name: self.name) @first_name, @last_name = self.name.split end class << self - def google(name: nil, email: nil, uid: Number.number(9).to_s) + def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s) auth = Omniauth.new(name: name, email: email) { provider: 'google_oauth2', @@ -44,7 +44,7 @@ def google(name: nil, email: nil, uid: Number.number(9).to_s) profile: "https://plus.google.com/#{uid}", picture: image, gender: gender, - birthday: Date.backward(36_400).strftime('%Y-%m-%d'), + birthday: Date.backward(days: 36_400).strftime('%Y-%m-%d'), local: 'en', hd: "#{Company.name.downcase}.com" }, @@ -52,7 +52,7 @@ def google(name: nil, email: nil, uid: Number.number(9).to_s) 'iss' => 'accounts.google.com', 'at_hash' => Crypto.md5, 'email_verified' => true, - 'sub' => Number.number(28).to_s, + 'sub' => Number.number(digits: 28).to_s, 'azp' => 'APP_ID', 'email' => auth.email, 'aud' => 'APP_ID', @@ -64,8 +64,7 @@ def google(name: nil, email: nil, uid: Number.number(9).to_s) } end - def facebook(name: nil, email: nil, username: nil, - uid: Number.number(7).to_s) + def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s) auth = Omniauth.new(name: name, email: email) username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}" { @@ -93,7 +92,7 @@ def facebook(name: nil, email: nil, username: nil, link: "http://www.facebook.com/#{username}", username: username, location: { - id: Number.number(9).to_s, + id: Number.number(digits: 9).to_s, name: city_state }, gender: gender, @@ -107,7 +106,7 @@ def facebook(name: nil, email: nil, username: nil, } end - def twitter(name: nil, nickname: nil, uid: Number.number(6).to_s) + def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s) auth = Omniauth.new(name: name) nickname ||= auth.name.downcase.delete(' ') location = city_state @@ -180,7 +179,7 @@ def twitter(name: nil, nickname: nil, uid: Number.number(6).to_s) } end - def linkedin(name: nil, email: nil, uid: Number.number(6).to_s) + def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s) auth = Omniauth.new(name: name, email: email) first_name = auth.first_name.downcase last_name = auth.last_name.downcase @@ -243,7 +242,7 @@ def linkedin(name: nil, email: nil, uid: Number.number(6).to_s) } end - def github(name: nil, email: nil, uid: Number.number(8).to_s) + def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s) auth = Omniauth.new(name: name, email: email) login = auth.name.downcase.tr(' ', '-') html_url = "https://github.com/#{login}" @@ -294,8 +293,8 @@ def github(name: nil, email: nil, uid: Number.number(8).to_s) public_gists: random_number_from_range(1..1000), followers: random_number_from_range(1..1000), following: random_number_from_range(1..1000), - created_at: Time.backward(36_400).iso8601, - updated_at: Time.backward(2).iso8601 + created_at: Time.backward(days: 36_400).iso8601, + updated_at: Time.backward(days: 2).iso8601 } } } diff --git a/lib/faker/default/phone_number.rb b/lib/faker/default/phone_number.rb index 143dac1f23..70b0be6c4e 100644 --- a/lib/faker/default/phone_number.rb +++ b/lib/faker/default/phone_number.rb @@ -40,7 +40,7 @@ def exchange_code # US and Canada only # Can be used for both extensions and last four digits of phone number. # Since extensions can be of variable length, this method taks a length parameter - def subscriber_number(length = 4) + def subscriber_number(length: 4) rand.to_s[2..(1 + length)] end diff --git a/lib/faker/default/placeholdit.rb b/lib/faker/default/placeholdit.rb index a798501151..84ccdb673d 100644 --- a/lib/faker/default/placeholdit.rb +++ b/lib/faker/default/placeholdit.rb @@ -5,7 +5,7 @@ class Placeholdit < Base class << self SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze - def image(size = '300x300', format = 'png', background_color = nil, text_color = nil, text = nil) + def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil) background_color = generate_color if background_color == :random text_color = generate_color if text_color == :random diff --git a/lib/faker/default/relationship.rb b/lib/faker/default/relationship.rb index 3e9e48fb08..1370496cb5 100644 --- a/lib/faker/default/relationship.rb +++ b/lib/faker/default/relationship.rb @@ -5,7 +5,7 @@ class Relationship < Base flexible :relationship class << self - def familial(connection = nil) + def familial(connection: nil) familial_connections = translate('faker.relationship.familial').keys if connection.nil? diff --git a/lib/faker/default/source.rb b/lib/faker/default/source.rb index b83e240f3b..9e2539ed1b 100644 --- a/lib/faker/default/source.rb +++ b/lib/faker/default/source.rb @@ -3,7 +3,7 @@ module Faker class Source < Base class << self - def hello_world(lang = :ruby) + def hello_world(lang: :ruby) fetch("source.hello_world.#{lang}") end @@ -12,7 +12,7 @@ def print(str: 'some string', lang: :ruby) code.gsub('faker_string_to_print', str) end - def print_1_to_10(lang = :ruby) + def print_1_to_10(lang: :ruby) fetch("source.print_1_to_10.#{lang}") end end diff --git a/lib/faker/default/south_africa.rb b/lib/faker/default/south_africa.rb index e45cbfc7a4..5926cd77dc 100644 --- a/lib/faker/default/south_africa.rb +++ b/lib/faker/default/south_africa.rb @@ -44,7 +44,7 @@ def trust_registration_number end def vat_number - Faker::Finance.vat_number('ZA') + Faker::Finance.vat_number(country: 'ZA') end end end diff --git a/lib/faker/default/string.rb b/lib/faker/default/string.rb index f394daf7f4..91a0523253 100644 --- a/lib/faker/default/string.rb +++ b/lib/faker/default/string.rb @@ -3,7 +3,7 @@ module Faker class String < Base class << self - def random(length = 32) + def random(length: 32) utf8string select_a length end diff --git a/lib/faker/default/stripe.rb b/lib/faker/default/stripe.rb index bbf2ed85c3..44f2b7db67 100644 --- a/lib/faker/default/stripe.rb +++ b/lib/faker/default/stripe.rb @@ -3,7 +3,7 @@ module Faker class Stripe < Base class << self - def valid_card(card_type = nil) + def valid_card(card_type: nil) valid_cards = translate('faker.stripe.valid_cards').keys if card_type.nil? @@ -18,7 +18,7 @@ def valid_card(card_type = nil) fetch('stripe.valid_cards.' + card_type) end - def valid_token(card_type = nil) + def valid_token(card_type: nil) valid_tokens = translate('faker.stripe.valid_tokens').keys if card_type.nil? @@ -33,7 +33,7 @@ def valid_token(card_type = nil) fetch('stripe.valid_tokens.' + card_type) end - def invalid_card(card_error = nil) + def invalid_card(card_error: nil) invalid_cards = translate('faker.stripe.invalid_cards').keys if card_error.nil? @@ -57,7 +57,7 @@ def year rand_in_range(start_year, start_year + 5).to_s end - def ccv(card_type = nil) + def ccv(card_type: nil) (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s end end diff --git a/lib/faker/default/time.rb b/lib/faker/default/time.rb index 5004f876a8..1ffe0937f2 100644 --- a/lib/faker/default/time.rb +++ b/lib/faker/default/time.rb @@ -13,17 +13,17 @@ class Time < Faker::Date }.freeze class << self - def between(from, to, period = :all, format = nil) + def between(from, to, period: :all, format: nil) time = period == :between ? rand(from..to) : date_with_random_time(super(from, to), period) time_with_format(time, format) end - def forward(days = 365, period = :all, format = nil) - time_with_format(date_with_random_time(super(days), period), format) + def forward(days: 365, period: :all, format: nil) + time_with_format(date_with_random_time(super(days: days), period), format) end - def backward(days = 365, period = :all, format = nil) - time_with_format(date_with_random_time(super(days), period), format) + def backward(days: 365, period: :all, format: nil) + time_with_format(date_with_random_time(super(days: days), period), format) end private diff --git a/lib/faker/default/twitter.rb b/lib/faker/default/twitter.rb index be63fd286a..815465a9df 100644 --- a/lib/faker/default/twitter.rb +++ b/lib/faker/default/twitter.rb @@ -5,49 +5,49 @@ class Twitter < Base class << self def user(include_status: true, include_email: false) user_id = id - background_image_url = Faker::LoremPixel.image('600x400') # TODO: Make the dimensions change - profile_image_url = Faker::Avatar.image(user_id, '48x48') + background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change + profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48') user = { id: user_id, id_str: user_id.to_s, - contributors_enabled: Faker::Boolean.boolean(0.1), + contributors_enabled: Faker::Boolean.boolean(true_ratio: 0.1), created_at: created_at, - default_profile_image: Faker::Boolean.boolean(0.1), - default_profile: Faker::Boolean.boolean(0.1), + default_profile_image: Faker::Boolean.boolean(true_ratio: 0.1), + default_profile: Faker::Boolean.boolean(true_ratio: 0.1), description: Faker::Lorem.sentence, entities: user_entities, - favourites_count: Faker::Number.between(1, 100_000), + favourites_count: Faker::Number.between(to: 1, from: 100_000), follow_request_sent: false, - followers_count: Faker::Number.between(1, 10_000_000), + followers_count: Faker::Number.between(to: 1, from: 10_000_000), following: false, - friends_count: Faker::Number.between(1, 100_000), - geo_enabled: Faker::Boolean.boolean(0.1), - is_translation_enabled: Faker::Boolean.boolean(0.1), - is_translator: Faker::Boolean.boolean(0.1), + friends_count: Faker::Number.between(to: 1, from: 100_000), + geo_enabled: Faker::Boolean.boolean(true_ratio: 0.1), + is_translation_enabled: Faker::Boolean.boolean(true_ratio: 0.1), + is_translator: Faker::Boolean.boolean(true_ratio: 0.1), lang: Faker::Address.country_code, - listed_count: Faker::Number.between(1, 1000), + listed_count: Faker::Number.between(to: 1, from: 1000), location: "#{Faker::Address.city}, #{Faker::Address.state_abbr}, #{Faker::Address.country_code}", name: Faker::Name.name, notifications: false, profile_background_color: Faker::Color.hex_color, profile_background_image_url_https: background_image_url, profile_background_image_url: background_image_url.sub('https://', 'http://'), - profile_background_tile: Faker::Boolean.boolean(0.1), - profile_banner_url: Faker::LoremPixel.image('1500x500'), + profile_background_tile: Faker::Boolean.boolean(true_ratio: 0.1), + profile_banner_url: Faker::LoremPixel.image(size: '1500x500'), profile_image_url_https: profile_image_url, profile_image_url: profile_image_url.sub('https://', 'http://'), profile_link_color: Faker::Color.hex_color, profile_sidebar_border_color: Faker::Color.hex_color, profile_sidebar_fill_color: Faker::Color.hex_color, profile_text_color: Faker::Color.hex_color, - profile_use_background_image: Faker::Boolean.boolean(0.4), - protected: Faker::Boolean.boolean(0.1), + profile_use_background_image: Faker::Boolean.boolean(true_ratio: 0.4), + protected: Faker::Boolean.boolean(true_ratio: 0.1), screen_name: screen_name, - statuses_count: Faker::Number.between(1, 100_000), + statuses_count: Faker::Number.between(to: 1, from: 100_000), time_zone: Faker::Address.time_zone, - url: Faker::Internet.url('example.com'), + url: Faker::Internet.url(host: 'example.com'), utc_offset: utc_offset, - verified: Faker::Boolean.boolean(0.1) + verified: Faker::Boolean.boolean(true_ratio: 0.1) } user[:status] = Faker::Twitter.status(include_user: false) if include_status user[:email] = Faker::Internet.safe_email if include_email @@ -63,7 +63,7 @@ def status(include_user: true, include_photo: false) coordinates: nil, created_at: created_at, entities: status_entities(include_photo: include_photo), - favorite_count: Faker::Number.between(1, 10_000), + favorite_count: Faker::Number.between(to: 1, from: 10_000), favorited: false, geo: nil, in_reply_to_screen_name: nil, @@ -74,11 +74,11 @@ def status(include_user: true, include_photo: false) lang: Faker::Address.country_code, nil: nil, place: nil, - possibly_sensitive: Faker::Boolean.boolean(0.1), - retweet_count: Faker::Number.between(1, 10_000), + possibly_sensitive: Faker::Boolean.boolean(true_ratio: 0.1), + retweet_count: Faker::Number.between(to: 1, from: 10_000), retweeted_status: nil, retweeted: false, - source: "#{Faker::Company.name}", + source: "#{Faker::Company.name}", text: Faker::Lorem.sentence, truncated: false } @@ -88,13 +88,13 @@ def status(include_user: true, include_photo: false) end def screen_name - Faker::Internet.username(nil, ['_'])[0...20] + Faker::Internet.username(specifier: nil, separators: ['_'])[0...20] end private def id - Faker::Number.between(1, 9_223_372_036_854_775_807) + Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807) end def created_at @@ -102,7 +102,7 @@ def created_at end def utc_offset - Faker::Number.between(-43_200, 50_400) + Faker::Number.between(to: -43_200, from: 50_400) end def user_entities @@ -130,7 +130,7 @@ def status_entities(include_photo: false) def photo_entity # TODO: Dynamic image sizes # TODO: Return accurate indices - media_url = Faker::LoremPixel.image('1064x600') + media_url = Faker::LoremPixel.image(size: '1064x600') media_id = id { id: media_id, @@ -141,9 +141,9 @@ def photo_entity ], media_url: media_url.sub('https://', 'http://'), media_url_https: media_url, - url: Faker::Internet.url('example.com'), + url: Faker::Internet.url(host: 'example.com'), display_url: 'example.com', - expanded_url: Faker::Internet.url('example.com'), + expanded_url: Faker::Internet.url(host: 'example.com'), type: 'photo', sizes: { medium: { diff --git a/lib/faker/default/types.rb b/lib/faker/default/types.rb index aae69c7654..102719c89b 100644 --- a/lib/faker/default/types.rb +++ b/lib/faker/default/types.rb @@ -7,7 +7,7 @@ class Types < Base COMPLEX_TYPES = %i[hash array].freeze class << self - def rb_string(words = 1) + def rb_string(words: 1) resolved_num = resolve(words) word_list = translate('faker.lorem.words') @@ -20,23 +20,23 @@ def character sample(CHARACTERS) end - def rb_integer(from = 0, to = 100) + def rb_integer(from: 0, to: 100) rand(from..to).to_i end - def rb_hash(key_count = 1, type = random_type) + def rb_hash(key_count: 1, type: random_type) {}.tap do |hsh| - Lorem.words(key_count * 2).uniq.first(key_count).each do |s| + Lorem.words(num: key_count * 2).uniq.first(key_count).each do |s| hsh.merge!(s.to_sym => type) end end end - def complex_rb_hash(key_count = 1) - rb_hash(key_count, random_complex_type) + def complex_rb_hash(key_count: 1) + rb_hash(key_count: key_count, type: random_complex_type) end - def rb_array(len = 1) + def rb_array(len: 1) [].tap do |ar| len.times do ar.push random_type diff --git a/lib/faker/default/vehicle.rb b/lib/faker/default/vehicle.rb index d9793b704d..864e7c8812 100644 --- a/lib/faker/default/vehicle.rb +++ b/lib/faker/default/vehicle.rb @@ -26,7 +26,7 @@ def make fetch('vehicle.makes') end - def model(make_of_model = '') + def model(make_of_model: '') return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty? fetch("vehicle.models_by_make.#{make_of_model}") @@ -35,7 +35,7 @@ def model(make_of_model = '') def make_and_model m = make - "#{m} #{model(m)}" + "#{m} #{model(make_of_model: m)}" end def style @@ -82,16 +82,16 @@ def doors alias door_count doors def year - Faker::Time.backward(rand_in_range(365, 5475), :all, '%Y').to_i + Faker::Time.backward(days: rand_in_range(365, 5475), period: :all, format: '%Y').to_i end - def mileage(min = MILEAGE_MIN, max = MILEAGE_MAX) + def mileage(min: MILEAGE_MIN, max: MILEAGE_MAX) rand_in_range(min, max) end alias kilometrage mileage - def license_plate(state_abreviation = '') + def license_plate(state_abreviation: '') return regexify(bothify(fetch('vehicle.license_plate'))) if state_abreviation.empty? key = 'vehicle.license_plate_by_state.' + state_abreviation diff --git a/lib/faker/default/world_cup.rb b/lib/faker/default/world_cup.rb index a06b3afebb..bf3c2744bf 100644 --- a/lib/faker/default/world_cup.rb +++ b/lib/faker/default/world_cup.rb @@ -15,11 +15,11 @@ def stadium fetch('world_cup.stadiums') end - def group(group = 'group_A') + def group(group: 'group_A') fetch("world_cup.groups.#{group}") end - def roster(country = 'Egypt', type = 'coach') + def roster(country: 'Egypt', type: 'coach') fetch("world_cup.rosters.#{country}.#{type}") end end diff --git a/lib/faker/e b/lib/faker/e new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/faker/movies/star_wars.rb b/lib/faker/movies/star_wars.rb index 976e93faae..27d8c64840 100644 --- a/lib/faker/movies/star_wars.rb +++ b/lib/faker/movies/star_wars.rb @@ -44,7 +44,7 @@ def wookiee_sentence sentence + sample(['.', '?', '!']) end - def quote(character = nil) + def quote(character: nil) quoted_characters = translate('faker.star_wars.quotes') if character.nil? diff --git a/test/faker/books/test_lovecraft.rb b/test/faker/books/test_lovecraft.rb index 86b2b76315..4509905525 100644 --- a/test/faker/books/test_lovecraft.rb +++ b/test/faker/books/test_lovecraft.rb @@ -10,13 +10,13 @@ def setup # Words delivered by this request should be on the wordlist. def test_words - @words = @tester.words(1000) + @words = @tester.words(num: 1000) @words.each { |w| assert @wordlist.include?(w) } end # Words should not return any word with spaces def test_words_without_spaces - @words = @tester.words(1000) + @words = @tester.words(num: 1000) @words.each { |w| assert !w.match(/\s/) } end @@ -31,15 +31,15 @@ def test_word_without_spaces end def test_exact_count_param - assert(@tester.words(2).length == 2) - assert(@tester.sentences(2).length == 2) - assert(@tester.paragraphs(2).length == 2) + assert(@tester.words(num: 2).length == 2) + assert(@tester.sentences(sentence_count: 2).length == 2) + assert(@tester.paragraphs(paragraph_count: 2).length == 2) end def test_range_count_param - ws = @tester.words(2..5) - ss = @tester.sentences(2..5) - ps = @tester.paragraphs(2..5) + ws = @tester.words(num: 2..5) + ss = @tester.sentences(sentence_count: 2..5) + ps = @tester.paragraphs(paragraph_count: 2..5) assert(ws.length >= 2 && ws.length <= 5) assert(ss.length >= 2 && ss.length <= 5) @@ -47,9 +47,9 @@ def test_range_count_param end def test_array_count_param - ws = @tester.words([1, 4]) - ss = @tester.sentences([1, 4]) - ps = @tester.paragraphs([1, 4]) + ws = @tester.words(num: [1, 4]) + ss = @tester.sentences(sentence_count: [1, 4]) + ps = @tester.paragraphs(paragraph_count: [1, 4]) assert(ws.length == 1 || ws.length == 4) assert(ss.length == 1 || ss.length == 4) @@ -57,9 +57,9 @@ def test_array_count_param end def test_words_with_large_count_params - exact = @tester.words(500) - range = @tester.words(250..500) - array = @tester.words([250, 500]) + exact = @tester.words(num: 500) + range = @tester.words(num: 250..500) + array = @tester.words(num: [250, 500]) assert(exact.length == 500) assert(range.length >= 250 && range.length <= 500) @@ -67,7 +67,7 @@ def test_words_with_large_count_params end def test_paragraph_char_count - paragraph = @tester.paragraph_by_chars(256) + paragraph = @tester.paragraph_by_chars assert(paragraph.length == 256) end diff --git a/test/faker/default/test_alphanum.rb b/test/faker/default/test_alphanum.rb index 1a5f3d9dc1..e1fe3d8cbf 100644 --- a/test/faker/default/test_alphanum.rb +++ b/test/faker/default/test_alphanum.rb @@ -8,10 +8,10 @@ def setup end def alpha - assert @tester.alpha(5).match(/[a-z]{5}/) + assert @tester.alpha(char_count: 5).match(/[a-z]{5}/) end def alphanum - assert @tester.alphanumeric(5).match(/[a-z0-9]{5}/) + assert @tester.alphanumeric(char_count: 5).match(/[a-z0-9]{5}/) end end diff --git a/test/faker/default/test_avatar.rb b/test/faker/default/test_avatar.rb index 46644d6016..3760bf6c0d 100644 --- a/test/faker/default/test_avatar.rb +++ b/test/faker/default/test_avatar.rb @@ -12,34 +12,34 @@ def test_avatar end def test_avatar_with_param - assert @tester.image('faker').match(%r{https:\/\/robohash\.org\/(.+)\.png})[1] == 'faker' + assert @tester.image(slug: 'faker').match(%r{https:\/\/robohash\.org\/(.+)\.png})[1] == 'faker' end def test_avatar_with_correct_size - assert @tester.image('faker', '150x320').match(%r{https:\/\/robohash\.org\/faker\.png\?size=(.+)&.*})[1] == '150x320' + assert @tester.image(slug: 'faker', size: '150x320').match(%r{https:\/\/robohash\.org\/faker\.png\?size=(.+)&.*})[1] == '150x320' end def test_avatar_with_incorrect_size assert_raise ArgumentError do - @tester.image(nil, '150x320z') + @tester.image(slug: nil, size: '150x320z') end end def test_avatar_with_supported_format - assert @tester.image('faker', '300x300', 'jpg').match(%r{https:\/\/robohash\.org\/faker\.jpg}) + assert @tester.image(slug: 'faker', size: '300x300', format: 'jpg').match(%r{https:\/\/robohash\.org\/faker\.jpg}) end def test_avatar_with_incorrect_format assert_raise ArgumentError do - @tester.image(nil, '300x300', 'wrong_format') + @tester.image(slug: nil, size: '300x300', format: 'wrong_format') end end def test_avatar_with_set - assert @tester.image('faker', '300x300', 'jpg', 'set2').match(%r{https:\/\/robohash\.org\/faker\.jpg.*set=set2}) + assert @tester.image(slug: 'faker', size: '300x300', format: 'jpg', set: 'set2').match(%r{https:\/\/robohash\.org\/faker\.jpg.*set=set2}) end def test_avatar_with_bgset - assert @tester.image('faker', '300x300', 'jpg', 'set1', 'bg1').match(%r{https:\/\/robohash\.org\/faker\.jpg.*bgset=bg1}) + assert @tester.image(slug: 'faker', size: '300x300', format: 'jpg', set: 'set1', bgset: 'bg1').match(%r{https:\/\/robohash\.org\/faker\.jpg.*bgset=bg1}) end end diff --git a/test/faker/default/test_faker_bank.rb b/test/faker/default/test_faker_bank.rb index e9789ad1c2..38914f1e9f 100644 --- a/test/faker/default/test_faker_bank.rb +++ b/test/faker/default/test_faker_bank.rb @@ -21,9 +21,9 @@ def test_routing_number_with_format def test_account_number assert Faker::Bank.account_number.match(/\d{10}/) - assert Faker::Bank.account_number(12).match(/\d{12}/) + assert Faker::Bank.account_number(digits: 12).match(/\d{12}/) - assert Faker::Bank.account_number(100).match(/\d{100}/) + assert Faker::Bank.account_number(digits: 100).match(/\d{100}/) end def test_name @@ -40,308 +40,308 @@ def test_iban_default # Andorra def test_iban_ad - account = @tester.iban('ad') + account = @tester.iban(country_code: 'ad') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}\d{8}[A-Z0-9]{12}$/) end # United Arab Emirates def test_iban_ae - account = @tester.iban('ae') + account = @tester.iban(country_code: 'ae') assert account.length == 23 assert account.match(/^#{IBAN_HEADER}\d{19}$/) end # Albania def test_iban_al - account = @tester.iban('al') + account = @tester.iban(country_code: 'al') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}\d{8}[A-Z0-9]{16}$/) end # Austria def test_iban_at - account = @tester.iban('at') + account = @tester.iban(country_code: 'at') assert account.length == 20 assert account.match(/^#{IBAN_HEADER}\d{16}$/) end # Azerbaijan, Republic of def test_iban_az - account = @tester.iban('az') + account = @tester.iban(country_code: 'az') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{20}$/) end # Bosnia def test_iban_ba - account = @tester.iban('ba') + account = @tester.iban(country_code: 'ba') assert account.length == 20 assert account.match(/^#{IBAN_HEADER}\d{16}$/) end # Belgium def test_iban_be - account = @tester.iban('be') + account = @tester.iban(country_code: 'be') assert account.length == 16 assert account.match(/^#{IBAN_HEADER}\d{12}$/) end # Bulgaria def test_iban_bg - account = @tester.iban('bg') + account = @tester.iban(country_code: 'bg') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{6}[A-Z0-9]{8}$/) end # Bahrain def test_iban_bh - account = @tester.iban('bh') + account = @tester.iban(country_code: 'bh') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{14}$/) end # Brazil def test_iban_br - account = @tester.iban('br') + account = @tester.iban(country_code: 'br') assert account.length == 29 assert account.match(/^#{IBAN_HEADER}[0-9]{8}[0-9]{5}[0-9]{10}[A-Z]{1}[A-Z0-9]{1}$/) end # Switzerland def test_iban_ch - account = @tester.iban('ch') + account = @tester.iban(country_code: 'ch') assert account.length == 21 assert account.match(/^#{IBAN_HEADER}\d{5}[A-Z0-9]{12}$/) end # Costa Rica def test_iban_cr - account = @tester.iban('cr') + account = @tester.iban(country_code: 'cr') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}0\d{3}\d{14}$/) end # Cyprus def test_iban_cy - account = @tester.iban('cy') + account = @tester.iban(country_code: 'cy') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}\d{8}[A-Z0-9]{16}$/) end # Czech Republic def test_iban_cz - account = @tester.iban('cz') + account = @tester.iban(country_code: 'cz') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}\d{20}$/) end # Germany def test_iban_de - account = @tester.iban('de') + account = @tester.iban(country_code: 'de') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}\d{18}$/) end # Denmark def test_iban_dk - account = @tester.iban('dk') + account = @tester.iban(country_code: 'dk') assert account.length == 18 assert account.match(/^#{IBAN_HEADER}\d{14}$/) end # Dominican Republic def test_iban_do - account = @tester.iban('do') + account = @tester.iban(country_code: 'do') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{20}$/) end # Estonia def test_iban_ee - account = @tester.iban('ee') + account = @tester.iban(country_code: 'ee') assert account.length == 20 assert account.match(/^#{IBAN_HEADER}\d{16}$/) end # Spain def test_iban_es - account = @tester.iban('es') + account = @tester.iban(country_code: 'es') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}\d{20}$/) end # Finland def test_iban_fi - account = @tester.iban('fi') + account = @tester.iban(country_code: 'fi') assert account.length == 18 assert account.match(/^#{IBAN_HEADER}\d{14}$/) end # Faroe Islands def test_iban_fo - account = @tester.iban('fo') + account = @tester.iban(country_code: 'fo') assert account.length == 18 assert account.match(/^#{IBAN_HEADER}\d{14}$/) end # France def test_iban_fr - account = @tester.iban('fr') + account = @tester.iban(country_code: 'fr') assert account.length == 27 assert account.match(/^#{IBAN_HEADER}\d{10}[A-Z0-9]{11}\d{2}$/) end # United Kingdom def test_iban_gb - account = @tester.iban('gb') + account = @tester.iban(country_code: 'gb') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{14}$/) end # Georgia def test_iban_ge - account = @tester.iban('ge') + account = @tester.iban(country_code: 'ge') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}[A-Z]{2}\d{16}$/) end # Gibraltar def test_iban_gi - account = @tester.iban('gi') + account = @tester.iban(country_code: 'gi') assert account.length == 23 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{15}$/) end # Greenland def test_iban_gl - account = @tester.iban('gl') + account = @tester.iban(country_code: 'gl') assert account.length == 18 assert account.match(/^#{IBAN_HEADER}\d{14}$/) end # Greece def test_iban_gr - account = @tester.iban('gr') + account = @tester.iban(country_code: 'gr') assert account.length == 27 assert account.match(/^#{IBAN_HEADER}\d{7}[A-Z0-9]{16}$/) end # Guatemala def test_iban_gt - account = @tester.iban('gt') + account = @tester.iban(country_code: 'gt') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}[A-Z0-9]{4}\d{2}\d{2}[A-Z0-9]{16}$/) end # Croatia def test_iban_hr - account = @tester.iban('hr') + account = @tester.iban(country_code: 'hr') assert account.length == 21 assert account.match(/^#{IBAN_HEADER}\d{17}$/) end # Hungary def test_iban_hu - account = @tester.iban('hu') + account = @tester.iban(country_code: 'hu') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}\d{24}$/) end # Ireland def test_iban_ie - account = @tester.iban('ie') + account = @tester.iban(country_code: 'ie') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{14}$/) end # Israel def test_iban_il - account = @tester.iban('il') + account = @tester.iban(country_code: 'il') assert account.length == 23 assert account.match(/^#{IBAN_HEADER}\d{19}$/) end # Iceland def test_iban_is - account = @tester.iban('is') + account = @tester.iban(country_code: 'is') assert account.length == 26 assert account.match(/^#{IBAN_HEADER}\d{22}$/) end # Italy def test_iban_it - account = @tester.iban('it') + account = @tester.iban(country_code: 'it') assert account.length == 27 assert account.match(/^#{IBAN_HEADER}[A-Z]\d{10}[A-Z0-9]{12}$/) end # Kuwait def test_iban_kw - account = @tester.iban('kw') + account = @tester.iban(country_code: 'kw') assert account.length == 30 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{22}$/) end # Kazakhstan def test_iban_kz - account = @tester.iban('kz') + account = @tester.iban(country_code: 'kz') assert account.length == 20 assert account.match(/^#{IBAN_HEADER}[0-9]{3}[A-Z0-9]{13}$/) end # Lebanon def test_iban_lb - account = @tester.iban('lb') + account = @tester.iban(country_code: 'lb') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}\d{4}[A-Z0-9]{20}$/) end # Liechtenstein def test_iban_li - account = @tester.iban('li') + account = @tester.iban(country_code: 'li') assert account.length == 21 assert account.match(/^#{IBAN_HEADER}\d{5}[A-Z0-9]{12}$/) end # Lithuania def test_iban_lt - account = @tester.iban('lt') + account = @tester.iban(country_code: 'lt') assert account.length == 20 assert account.match(/^#{IBAN_HEADER}\d{16}$/) end # Luxembourg def test_iban_lu - account = @tester.iban('lu') + account = @tester.iban(country_code: 'lu') assert account.length == 20 assert account.match(/^#{IBAN_HEADER}\d{3}[A-Z0-9]{13}$/) end # Latvia def test_iban_lv - account = @tester.iban('lv') + account = @tester.iban(country_code: 'lv') assert account.length == 21 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{13}$/) end # Monaco def test_iban_mc - account = @tester.iban('mc') + account = @tester.iban(country_code: 'mc') assert account.length == 27 assert account.match(/^#{IBAN_HEADER}\d{10}[A-Z0-9]{11}\d{2}$/) end # Moldova def test_iban_md - account = @tester.iban('md') + account = @tester.iban(country_code: 'md') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}[A-Z]{2}[A-Z0-9]{18}$/) end # Montenegro def test_iban_me - account = @tester.iban('me') + account = @tester.iban(country_code: 'me') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}\d{18}$/) @@ -349,175 +349,175 @@ def test_iban_me # Macedonia def test_iban_mk - account = @tester.iban('mk') + account = @tester.iban(country_code: 'mk') assert account.length == 19 assert account.match(/^#{IBAN_HEADER}\d{3}[A-Z0-9]{10}\d{2}$/) end # Mauritania def test_iban_mr - account = @tester.iban('mr') + account = @tester.iban(country_code: 'mr') assert account.length == 27 assert account.match(/^#{IBAN_HEADER}\d{23}$/) end # Malta def test_iban_mt - account = @tester.iban('mt') + account = @tester.iban(country_code: 'mt') assert account.length == 31 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{5}[A-Z0-9]{18}$/) end # Mauritius def test_iban_mu - account = @tester.iban('mu') + account = @tester.iban(country_code: 'mu') assert account.length == 30 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{19}[A-Z]{3}$/) end # Netherlands def test_iban_nl - account = @tester.iban('nl') + account = @tester.iban(country_code: 'nl') assert account.length == 18 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{10}$/) end # Norway def test_iban_no - account = @tester.iban('no') + account = @tester.iban(country_code: 'no') assert account.length == 15 assert account.match(/^#{IBAN_HEADER}\d{11}$/) end # Pakistan def test_iban_pk - account = @tester.iban('pk') + account = @tester.iban(country_code: 'pk') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{16}$/) end # Poland def test_iban_pl - account = @tester.iban('pl') + account = @tester.iban(country_code: 'pl') assert account.length == 28 assert account.match(/^#{IBAN_HEADER}\d{8}[A-Z0-9]{16}$/) end # Palestinian Territory, Occupied def test_iban_ps - account = @tester.iban('ps') + account = @tester.iban(country_code: 'ps') assert account.length == 29 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{21}$/) end # Portugal def test_iban_pt - account = @tester.iban('pt') + account = @tester.iban(country_code: 'pt') assert account.length == 25 assert account.match(/^#{IBAN_HEADER}\d{21}$/) end # Qatar def test_iban_qa - account = @tester.iban('qa') + account = @tester.iban(country_code: 'qa') assert account.length == 29 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{21}$/) end # Romania def test_iban_ro - account = @tester.iban('ro') + account = @tester.iban(country_code: 'ro') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}[A-Z0-9]{16}$/) end # Serbia def test_iban_rs - account = @tester.iban('rs') + account = @tester.iban(country_code: 'rs') assert account.length == 22 assert account.match(/^#{IBAN_HEADER}\d{18}$/) end # Saudi Arabia def test_iban_sa - account = @tester.iban('sa') + account = @tester.iban(country_code: 'sa') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}\d{2}[A-Z0-9]{18}$/) end # Sweden def test_iban_se - account = @tester.iban('se') + account = @tester.iban(country_code: 'se') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}\d{20}$/) end # Slovenia def test_iban_si - account = @tester.iban('si') + account = @tester.iban(country_code: 'si') assert account.length == 19 assert account.match(/^#{IBAN_HEADER}\d{15}$/) end # Slovakia def test_iban_sk - account = @tester.iban('sk') + account = @tester.iban(country_code: 'sk') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}\d{20}$/) end # San Marino def test_iban_sm - account = @tester.iban('sm') + account = @tester.iban(country_code: 'sm') assert account.length == 27 assert account.match(/^#{IBAN_HEADER}[A-Z]\d{10}[A-Z0-9]{12}$/) end # Timor-Leste def test_iban_tl - account = @tester.iban('tl') + account = @tester.iban(country_code: 'tl') assert account.length == 23 assert account.match(/^#{IBAN_HEADER}\d{19}$/) end # Tunisia def test_iban_tn - account = @tester.iban('tn') + account = @tester.iban(country_code: 'tn') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}\d{20}$/) end # Turkey def test_iban_tr - account = @tester.iban('tr') + account = @tester.iban(country_code: 'tr') assert account.length == 26 assert account.match(/^#{IBAN_HEADER}\d{5}[A-Z0-9]{17}$/) end # Ukraine def test_iban_ua - account = @tester.iban('ua') + account = @tester.iban(country_code: 'ua') assert account.length == 29 assert account.match(/^#{IBAN_HEADER}\d{25}$/) end # Virgin Islands, British def test_iban_vg - account = @tester.iban('vg') + account = @tester.iban(country_code: 'vg') assert account.length == 24 assert account.match(/^#{IBAN_HEADER}[A-Z]{4}\d{16}$/) end # Kosovo, Republic of def test_iban_xk - account = @tester.iban('xk') + account = @tester.iban(country_code: 'xk') assert account.length == 20 assert account.match(/^#{IBAN_HEADER}\d{16}$/) end def test_iban_invalid assert_raise ArgumentError.new('Could not find iban details for bad') do - @tester.iban('bad') + @tester.iban(country_code: 'bad') end end end diff --git a/test/faker/default/test_faker_chile_rut.rb b/test/faker/default/test_faker_chile_rut.rb index c000bf6858..e78fc5918e 100644 --- a/test/faker/default/test_faker_chile_rut.rb +++ b/test/faker/default/test_faker_chile_rut.rb @@ -8,8 +8,8 @@ def setup end def test_full_rut - assert @tester.full_rut(6, true) == '6-k' - assert @tester.full_rut(30_686_957, true) == '30686957-4' + assert @tester.full_rut(min_rut: 6, fixed: true) == '6-k' + assert @tester.full_rut(min_rut: 30_686_957, fixed: true) == '30686957-4' end def test_rut_length @@ -21,7 +21,7 @@ def test_rut_length # since the whole idea of the method revolves around calculating # the check digit for that specific rut. def test_check_digit - assert @tester.rut(30_686_957, true) == 30_686_957 + assert @tester.rut(min_rut: 30_686_957, fixed: true) == 30_686_957 assert @tester.dv == '4' end end diff --git a/test/faker/default/test_faker_code.rb b/test/faker/default/test_faker_code.rb index 2eb1b93012..95ed7494a5 100644 --- a/test/faker/default/test_faker_code.rb +++ b/test/faker/default/test_faker_code.rb @@ -24,7 +24,7 @@ def test_default_isbn_regexp end def test_default_isbn13_regexp - assert @tester.isbn(13).match(/^\d{12}-\d$/) + assert @tester.isbn(base: 13).match(/^\d{12}-\d$/) end def test_default_ean_regexp @@ -32,7 +32,7 @@ def test_default_ean_regexp end def test_default_ean8_regexp - assert @tester.ean(8).match(/^\d{8}$/) + assert @tester.ean(base: 8).match(/^\d{8}$/) end def test_rut diff --git a/test/faker/default/test_faker_commerce.rb b/test/faker/default/test_faker_commerce.rb index 3d5c34247f..be5c0749ae 100644 --- a/test/faker/default/test_faker_commerce.rb +++ b/test/faker/default/test_faker_commerce.rb @@ -16,7 +16,7 @@ def test_promotion_code end def test_promotion_code_should_have_specified_number_of_digits - assert @tester.promotion_code(3).match(/[A-Z][a-z]+[A-Z][a-z]+\d{3}/) + assert @tester.promotion_code(digits: 3).match(/[A-Z][a-z]+[A-Z][a-z]+\d{3}/) end def test_department @@ -24,11 +24,11 @@ def test_department end def test_single_department_should_not_contain_separators - assert_match(/\A[A-Za-z]+\z/, @tester.department(1)) + assert_match(/\A[A-Za-z]+\z/, @tester.department(max: 1)) end def test_department_should_have_ampersand_as_default_separator - assert_match ' & ', @tester.department(2, true) + assert_match ' & ', @tester.department(max: 2, fixed_amount: true) end def test_department_should_accept_localized_separator @@ -45,23 +45,23 @@ def test_department_should_accept_localized_separator I18n.config.available_locales += [:xy] I18n.backend.store_translations(:xy, data) I18n.with_locale(:xy) do - assert_match ' + ', @tester.department(2, true) + assert_match ' + ', @tester.department(max: 2, fixed_amount: true) end I18n.config.available_locales = @old_locales end def test_department_should_have_exact_number_of_categories_when_fixed_amount - assert_match(/\A([A-Za-z]+, ){8}[A-Za-z]+ & [A-Za-z]+\z/, @tester.department(10, true)) + assert_match(/\A([A-Za-z]+, ){8}[A-Za-z]+ & [A-Za-z]+\z/, @tester.department(max: 10, fixed_amount: true)) end def test_department_should_never_exceed_the_max_number_of_categories_when_random_amount 100.times do - assert_match(/\A([A-Za-z]+(, | & )){0,5}[A-Za-z]+\z/, @tester.department(6)) + assert_match(/\A([A-Za-z]+(, | & )){0,5}[A-Za-z]+\z/, @tester.department(max: 6)) end end def test_department_should_have_no_duplicate_categories - department = @tester.department(10, true) + department = @tester.department(max: 10, fixed_amount: true) departments = department.split(/[,& ]+/) assert_equal departments, departments.uniq diff --git a/test/faker/default/test_faker_company.rb b/test/faker/default/test_faker_company.rb index 6ed303ee7c..21b9a466cb 100644 --- a/test/faker/default/test_faker_company.rb +++ b/test/faker/default/test_faker_company.rb @@ -92,7 +92,7 @@ def test_polish_taxpayer_identification_number def test_polish_register_of_national_economy # 8 length should fail assert_raise ArgumentError do - @tester.polish_register_of_national_economy(8) + @tester.polish_register_of_national_economy(length: 8) end # 9 length number = @tester.polish_register_of_national_economy @@ -103,7 +103,7 @@ def test_polish_register_of_national_economy control_number = control_sum.modulo(11) == 10 ? 0 : control_sum.modulo(11) assert control_number == number[8].to_i # 14 length - number = @tester.polish_register_of_national_economy(14) + number = @tester.polish_register_of_national_economy(length: 14) control_sum = 0 [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8].each_with_index do |control, index| control_sum += control * number[index].to_i @@ -146,13 +146,14 @@ def test_south_african_trust_registration_number def test_luhn_algorithm # Odd length base for luhn algorithm - odd_base = Faker::Number.number([5, 7, 9, 11, 13].sample) + odd_base = Faker::Number.number(digits: [5, 7, 9, 11, 13].sample) odd_luhn_complement = @tester.send(:luhn_algorithm, odd_base).to_s odd_control = "#{odd_base}#{odd_luhn_complement}" # Even length base for luhn algorithm - even_base = Faker::Number.number([4, 6, 8, 10, 12].sample) + even_base = Faker::Number.number(digits: [4, 6, 8, 10, 12].sample) even_luhn_complement = @tester.send(:luhn_algorithm, even_base).to_s + even_control = "#{even_base}#{even_luhn_complement}" assert((luhn_checksum(odd_control) % 10).zero?) diff --git a/test/faker/default/test_faker_date.rb b/test/faker/default/test_faker_date.rb index debeed4d69..41d754c226 100644 --- a/test/faker/default/test_faker_date.rb +++ b/test/faker/default/test_faker_date.rb @@ -54,7 +54,7 @@ def test_forward today = Date.today 100.times do - random_date = @tester.forward(5) + random_date = @tester.forward(days: 5) assert random_date > today, "Expected > \"#{today}\", but got #{random_date}" end end @@ -63,14 +63,14 @@ def test_backward today = Date.today 100.times do - random_date = @tester.backward(5) + random_date = @tester.backward(days: 5) assert random_date < today, "Expected < \"#{today}\", but got #{random_date}" end end def test_return_type - random_forward = @tester.forward(5) - random_backward = @tester.backward(5) + random_forward = @tester.forward(days: 5) + random_backward = @tester.backward(days: 5) random_between = @tester.between(Date.today, Date.today + 5) [random_forward, random_backward, random_between].each do |result| @@ -93,7 +93,7 @@ def test_birthday birthdate_max = Date.new(t.year - min, t.month, t.day) 100.times do - birthday = @tester.birthday(min, max) + birthday = @tester.birthday(min_age: min, max_age: max) assert birthday >= birthdate_min, "Expect >= \"#{birthdate_min}\", but got #{birthday}" assert birthday <= birthdate_max, "Expect <= \"#{birthdate_max}\", but got #{birthday}" end @@ -103,7 +103,7 @@ def test_birthday_when_min_age_equals_max_age min = 0 max = 0 - birthday = @tester.birthday(min, max) + birthday = @tester.birthday(min_age: min, max_age: max) assert_equal birthday, Date.today end @@ -119,7 +119,7 @@ def test_birthday_on_newborns birthdays = [] 10.times do - birthday = @tester.birthday(min, max) + birthday = @tester.birthday(min_age: min, max_age: max) birthdays << birthday diff --git a/test/faker/default/test_faker_demographic.rb b/test/faker/default/test_faker_demographic.rb index 01ac2b7ab6..19e6693865 100644 --- a/test/faker/default/test_faker_demographic.rb +++ b/test/faker/default/test_faker_demographic.rb @@ -28,7 +28,7 @@ def test_sex end def test_height_imperial - assert @tester.height(:imperial).match(/\w+/) + assert @tester.height(unit: :imperial).match(/\w+/) end def test_height_metric diff --git a/test/faker/default/test_faker_dune.rb b/test/faker/default/test_faker_dune.rb index 17552290aa..2a6a942c74 100644 --- a/test/faker/default/test_faker_dune.rb +++ b/test/faker/default/test_faker_dune.rb @@ -25,13 +25,13 @@ def test_random_quote # test good match def test_random_character_quote - assert @tester.quote('paul').match(/\w+/) + assert @tester.quote(character: 'paul').match(/\w+/) end # test error on no match def test_invalid_quote assert_raise ArgumentError do - @tester.quote('Luke Skywalker') + @tester.quote(character: 'Luke Skywalker') end end @@ -41,13 +41,13 @@ def test_random_saying # test good match def test_random_source_saying - assert @tester.saying('fremen').match(/\w+/) + assert @tester.saying(source: 'fremen').match(/\w+/) end # test error on no match def test_invalid_saying assert_raise ArgumentError do - @tester.saying('Ewoks') + @tester.saying(source: 'Ewoks') end end end diff --git a/test/faker/default/test_faker_file.rb b/test/faker/default/test_faker_file.rb index a8975a4323..2850e02eff 100644 --- a/test/faker/default/test_faker_file.rb +++ b/test/faker/default/test_faker_file.rb @@ -27,7 +27,7 @@ def test_dir def test_dir_with_args assert @tester - .dir(2, '\\root\\', '\\') + .dir(segment_count: 2, root: '\\root\\', directory_separator: '\\') .match(%r{^\\root(\\([a-z\-_.]+)){2}$}) end end diff --git a/test/faker/default/test_faker_fillmurray.rb b/test/faker/default/test_faker_fillmurray.rb index c73b0d75e8..fc09f42058 100644 --- a/test/faker/default/test_faker_fillmurray.rb +++ b/test/faker/default/test_faker_fillmurray.rb @@ -8,28 +8,28 @@ def setup end def test_fillmurray - assert !@tester.image(false, '300', '300').match(%r{https:\/\/www\.fillmurray\.com\/(\d+)\/(\d+)}).nil? + assert !@tester.image(grayscale: false, width: '300', height: '300').match(%r{https:\/\/www\.fillmurray\.com\/(\d+)\/(\d+)}).nil? end def test_fillmurray_with_grayscale - assert @tester.image(true, '300', '300').match(%r{https:\/\/www\.fillmurray\.com\/(g?\/?)(\d+)\/(\d+)})[1] == 'g/' + assert @tester.image(grayscale: true, width: '300', height: '300').match(%r{https:\/\/www\.fillmurray\.com\/(g?\/?)(\d+)\/(\d+)})[1] == 'g/' end def test_fillmurray_with_incorrect_height_format assert_raise ArgumentError do - @tester.image(false, '300', 'nine-thousand') + @tester.image(grayscale: false, width: '300', height: 'nine-thousand') end end def test_fillmurray_with_incorrect_width_format assert_raise ArgumentError do - @tester.image(false, 'three-hundred') + @tester.image(grayscale: false, width: 'three-hundred') end end def test_fillmurray_with_incorrect_grayscale assert_raise ArgumentError do - @tester.image('gray', '300', '400') + @tester.image(grayscale: 'gray', width: '300', height: '400') end end end diff --git a/test/faker/default/test_faker_finance.rb b/test/faker/default/test_faker_finance.rb index cc2c7082f9..2b343f6078 100644 --- a/test/faker/default/test_faker_finance.rb +++ b/test/faker/default/test_faker_finance.rb @@ -13,17 +13,17 @@ def test_vat_number def test_vat_number_with_invalid_params assert_raise ArgumentError do - Faker::Finance.vat_number(Faker::Lorem.word) + Faker::Finance.vat_number(country: Faker::Lorem.word) end end def test_vat_number_with_valid_params Faker::Finance.vat_number_keys.each do |country| - assert Faker::Finance.vat_number(country).match(/\w+/) + assert Faker::Finance.vat_number(country: country).match(/\w+/) end end def test_south_african_vat_number - assert_match(/\AZA\d{10,11}\z/, Faker::Finance.vat_number('ZA')) + assert_match(/\AZA\d{10,11}\z/, Faker::Finance.vat_number(country: 'ZA')) end end diff --git a/test/faker/default/test_faker_hipster.rb b/test/faker/default/test_faker_hipster.rb index 830fedd7dc..ee567dd0e8 100644 --- a/test/faker/default/test_faker_hipster.rb +++ b/test/faker/default/test_faker_hipster.rb @@ -12,19 +12,19 @@ def setup # Words delivered by a standard request should be on the standard wordlist. def test_words - @words = @tester.words(1000) + @words = @tester.words(num: 1000) @words.each { |w| assert @standard_wordlist.include?(w) } end # Words should not return any word with spaces def test_words_without_spaces - @words = @tester.words(1000) + @words = @tester.words(num: 1000) @words.each { |w| assert !w.match(/\s/) } end # Words requested from the supplemental list should all be in that list. def test_supplemental_words - @words = @tester.words(10_000, true) + @words = @tester.words(num: 10_000, supplemental: true) @words.each { |w| assert @complete_wordlist.include?(w) } end @@ -42,15 +42,15 @@ def test_word_without_spaces end def test_exact_count_param - assert(@tester.words(2).length == 2) - assert(@tester.sentences(2).length == 2) - assert(@tester.paragraphs(2).length == 2) + assert(@tester.words(num: 2).length == 2) + assert(@tester.sentences(sentence_count: 2).length == 2) + assert(@tester.paragraphs(paragraph_count: 2).length == 2) end def test_range_count_param - ws = @tester.words(2..5) - ss = @tester.sentences(2..5) - ps = @tester.paragraphs(2..5) + ws = @tester.words(num: 2..5) + ss = @tester.sentences(sentence_count: 2..5) + ps = @tester.paragraphs(paragraph_count: 2..5) assert(ws.length >= 2 && ws.length <= 5) assert(ss.length >= 2 && ss.length <= 5) @@ -58,9 +58,9 @@ def test_range_count_param end def test_array_count_param - ws = @tester.words([1, 4]) - ss = @tester.sentences([1, 4]) - ps = @tester.paragraphs([1, 4]) + ws = @tester.words(num: [1, 4]) + ss = @tester.sentences(sentence_count: [1, 4]) + ps = @tester.paragraphs(paragraph_count: [1, 4]) assert(ws.length == 1 || ws.length == 4) assert(ss.length == 1 || ss.length == 4) @@ -68,9 +68,9 @@ def test_array_count_param end def test_words_with_large_count_params - exact = @tester.words(500) - range = @tester.words(250..500) - array = @tester.words([250, 500]) + exact = @tester.words(num: 500) + range = @tester.words(num: 250..500) + array = @tester.words(num: [250, 500]) assert(exact.length == 500) assert(range.length >= 250 && range.length <= 500) @@ -78,7 +78,7 @@ def test_words_with_large_count_params end def test_paragraph_char_count - paragraph = @tester.paragraph_by_chars(256) + paragraph = @tester.paragraph_by_chars(chars: 256) assert(paragraph.length == 256) end end diff --git a/test/faker/default/test_faker_internet.rb b/test/faker/default/test_faker_internet.rb index f35fe2ae51..5aeb8f1592 100644 --- a/test/faker/default/test_faker_internet.rb +++ b/test/faker/default/test_faker_internet.rb @@ -24,7 +24,7 @@ def test_safe_email end def test_username - assert @tester.username(0..3).match(/[a-z]+((_|\.)[a-z]+)?/) + assert @tester.username(specifier: 0..3).match(/[a-z]+((_|\.)[a-z]+)?/) assert @tester.username.match(/[a-z]+((_|\.)[a-z]+)?/) end @@ -33,39 +33,39 @@ def test_user_name_alias end def test_username_with_string_arg - assert @tester.username('bo peep').match(/(bo(_|\.)peep|peep(_|\.)bo)/) + assert @tester.username(specifier: 'bo peep').match(/(bo(_|\.)peep|peep(_|\.)bo)/) end def test_username_with_string_arg_determinism - deterministically_verify -> { @tester.username('bo peep') }, depth: 4 do |subject| + deterministically_verify -> { @tester.username(specifier: 'bo peep') }, depth: 4 do |subject| assert subject.match(/(bo(_|\.)peep|peep(_|\.)bo)/) end end def test_username_with_integer_arg (1..32).each do |min_length| - assert @tester.username(min_length).length >= min_length + assert @tester.username(specifier: min_length).length >= min_length end end def test_username_with_utf_8_arg # RUBY_VERSION < '2.4.0' is not able to downcase or upcase non-ascii strings if RUBY_VERSION < '2.4.0' - assert @tester.username('Łucja').match('Łucja') + assert @tester.username(specifier: 'Łucja').match('Łucja') else - assert @tester.username('Łucja').match('łucja') + assert @tester.username(specifier: 'Łucja').match('łucja') end end def test_username_with_very_large_integer_arg - exception = assert_raises(ArgumentError) { @tester.username(10_000_000) } + exception = assert_raises(ArgumentError) { @tester.username(specifier: 10_000_000) } assert_equal('Given argument is too large', exception.message) end def test_username_with_closed_range_arg (1..32).each do |min_length| (min_length..32).each do |max_length| - l = @tester.username((min_length..max_length)).length + l = @tester.username(specifier: (min_length..max_length)).length assert l >= min_length assert l <= max_length end @@ -75,7 +75,7 @@ def test_username_with_closed_range_arg def test_username_with_open_range_arg (1..32).each do |min_length| (min_length + 1..33).each do |max_length| - l = @tester.username((min_length...max_length)).length + l = @tester.username(specifier: (min_length...max_length)).length assert l >= min_length assert l <= max_length - 1 end @@ -85,7 +85,7 @@ def test_username_with_open_range_arg def test_username_with_range_and_separators (1..32).each do |min_length| (min_length + 1..33).each do |max_length| - u = @tester.username((min_length...max_length), %w[=]) + u = @tester.username(specifier: (min_length...max_length), separators: %w[=]) assert u.length.between? min_length, max_length - 1 assert u.match(/\A[a-z]+((=)?[a-z]*)*\z/) end @@ -98,21 +98,21 @@ def test_password def test_password_with_integer_arg (1..32).each do |min_length| - assert @tester.password(min_length).length >= min_length + assert @tester.password(min_length: min_length).length >= min_length end end def test_password_max_with_integer_arg (1..32).each do |min_length| max_length = min_length + 4 - assert @tester.password(min_length, max_length).length <= max_length + assert @tester.password(min_length: min_length, max_length: max_length).length <= max_length end end def test_password_could_achieve_max_length passwords = [] 64.times do - passwords << @tester.password(14, 16) + passwords << @tester.password(min_length: 14, max_length: 16) end assert passwords.select { |item| item.length == 16 }.size >= 1 end @@ -122,15 +122,15 @@ def test_password_with_mixed_case end def test_password_without_mixed_case - assert @tester.password(8, 12, false).match(/[^A-Z]+/) + assert @tester.password(min_length: 8, max_length: 12, mix_case: false).match(/[^A-Z]+/) end def test_password_with_special_chars - assert @tester.password(8, 12, true, true).match(/[!@#\$%\^&\*]+/) + assert @tester.password(min_length: 8, max_length: 12, mix_case: true, special_chars: true).match(/[!@#\$%\^&\*]+/) end def test_password_without_special_chars - assert @tester.password(8, 12, true).match(/[^!@#\$%\^&\*]+/) + assert @tester.password(min_length: 8, max_length: 12, mix_case: true).match(/[^!@#\$%\^&\*]+/) end def test_domain_name_without_subdomain @@ -138,7 +138,7 @@ def test_domain_name_without_subdomain end def test_domain_name_with_subdomain - assert @tester.domain_name(true).match(/\w+\.\w+\.\w+/) + assert @tester.domain_name(subdomain: true).match(/\w+\.\w+\.\w+/) end def test_domain_word @@ -216,14 +216,14 @@ def test_ip_v4_cidr def test_mac_address assert_equal 5, @tester.mac_address.count(':') - assert_equal 5, @tester.mac_address('').count(':') + assert_equal 5, @tester.mac_address(prefix: '').count(':') 100.times do assert @tester.mac_address.split(':').map { |d| d.to_i(16) }.max <= 255 end - assert @tester.mac_address('fa:fa:fa').start_with?('fa:fa:fa') - assert @tester.mac_address('01:02').start_with?('01:02') + assert @tester.mac_address(prefix: 'fa:fa:fa').start_with?('fa:fa:fa') + assert @tester.mac_address(prefix: '01:02').start_with?('01:02') end def test_ip_v6_address @@ -247,19 +247,19 @@ def test_slug end def test_slug_with_content_arg - assert @tester.slug('Foo bAr baZ').match(/^foo(_|\.|\-)bar(_|\.|\-)baz$/) + assert @tester.slug(words: 'Foo bAr baZ').match(/^foo(_|\.|\-)bar(_|\.|\-)baz$/) end def test_slug_with_unwanted_content_arg - assert @tester.slug('Foo.. bAr., baZ,,').match(/^foo(_|\.|\-)bar(_|\.|\-)baz$/) + assert @tester.slug(words: 'Foo.. bAr., baZ,,').match(/^foo(_|\.|\-)bar(_|\.|\-)baz$/) end def test_slug_with_glue_arg - assert @tester.slug(nil, '+').match(/^[a-z]+\+[a-z]+$/) + assert @tester.slug(words: nil, glue: '+').match(/^[a-z]+\+[a-z]+$/) end def test_url - assert @tester.url('domain.com', '/username', 'https').match(%r{^https:\/\/domain\.com\/username$}) + assert @tester.url(host: 'domain.com', path: '/username', scheme: 'https').match(%r{^https:\/\/domain\.com\/username$}) end def test_device_token @@ -271,14 +271,14 @@ def test_user_agent_with_no_argument end def test_user_agent_with_valid_argument - assert @tester.user_agent(:opera).match(/Opera/) - assert @tester.user_agent('opera').match(/Opera/) + assert @tester.user_agent(vendor: :opera).match(/Opera/) + assert @tester.user_agent(vendor: 'opera').match(/Opera/) end def test_user_agent_with_invalid_argument - assert @tester.user_agent(:ie).match(/Mozilla|Opera/) - assert @tester.user_agent(nil).match(/Mozilla|Opera/) - assert @tester.user_agent(1).match(/Mozilla|Opera/) + assert @tester.user_agent(vendor: :ie).match(/Mozilla|Opera/) + assert @tester.user_agent(vendor: nil).match(/Mozilla|Opera/) + assert @tester.user_agent(vendor: 1).match(/Mozilla|Opera/) end def test_uuid diff --git a/test/faker/default/test_faker_json.rb b/test/faker/default/test_faker_json.rb index 6bb061c7d0..4e9b1512f1 100644 --- a/test/faker/default/test_faker_json.rb +++ b/test/faker/default/test_faker_json.rb @@ -8,18 +8,18 @@ def setup end def test_shallow_json - json = Faker::Json.shallow_json(3, key: 'Name.first_name', value: 'Name.first_name') + json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) assert JSON.parse(json).flatten.length.equal?(6) end def test_add_depth_to_json - json = Faker::Json.shallow_json(3, key: 'Name.first_name', value: 'Name.first_name') - json = Faker::Json.add_depth_to_json(json, 3, key: 'Name.first_name', value: 'Name.first_name') + json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) + json = Faker::Json.add_depth_to_json(json: json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) assert JSON.parse(json).flatten[1].flatten.length.equal?(6) assert JSON.parse(json).flatten[3].flatten.length.equal?(6) assert JSON.parse(json).flatten[5].flatten.length.equal?(6) - json = Faker::Json.add_depth_to_json(json, 3, key: 'Name.first_name', value: 'Name.first_name') + json = Faker::Json.add_depth_to_json(json: json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) assert JSON.parse(json).flatten[1].flatten[1].flatten.length.equal?(6) assert JSON.parse(json).flatten[3].flatten[3].flatten.length.equal?(6) assert JSON.parse(json).flatten[5].flatten[5].flatten.length.equal?(6) diff --git a/test/faker/default/test_faker_lorem.rb b/test/faker/default/test_faker_lorem.rb index 3b2d96b7da..2d5579e9e5 100644 --- a/test/faker/default/test_faker_lorem.rb +++ b/test/faker/default/test_faker_lorem.rb @@ -23,24 +23,24 @@ def test_characters end def test_characters_negatives - assert_equal '', @tester.characters(-1) - assert_equal '', @tester.characters((-2..-1)) - assert_equal '', @tester.characters([-1, -2]) + assert_equal '', @tester.characters(char_count: -1) + assert_equal '', @tester.characters(char_count: (-2..-1)) + assert_equal '', @tester.characters(char_count: [-1, -2]) end def test_characters_with_args - 100.times { assert @tester.characters(500).length == 500 } + 100.times { assert @tester.characters(char_count: 500).length == 500 } end # Words delivered by a standard request should be on the standard wordlist. def test_standard_words - @words = @tester.words(1000) + @words = @tester.words(num: 1000) @words.each { |w| assert @standard_wordlist.include?(w) } end # Words requested from the supplemental list should all be in that list. def test_supplemental_words - @words = @tester.words(10_000, true) + @words = @tester.words(num: 10_000, supplemental: true) @words.each { |w| assert @complete_wordlist.include?(w) } end @@ -52,21 +52,21 @@ def test_word end def test_exact_sentence_word_count - assert_equal 2, @tester.sentence(2, false, 0).split(' ').length + assert_equal 2, @tester.sentence(word_count: 2, supplemental: false, random_words_to_add: 0).split(' ').length end def test_exact_count_param - assert(@tester.characters(2).length == 2) - assert(@tester.words(2).length == 2) - assert(@tester.sentences(2).length == 2) - assert(@tester.paragraphs(2).length == 2) + assert(@tester.characters(char_count: 2).length == 2) + assert(@tester.words(num: 2).length == 2) + assert(@tester.sentences(sentence_count: 2).length == 2) + assert(@tester.paragraphs(paragraph_count: 2).length == 2) end def test_range_count_param - cs = @tester.characters(2..5) - ws = @tester.words(2..5) - ss = @tester.sentences(2..5) - ps = @tester.paragraphs(2..5) + cs = @tester.characters(char_count: 2..5) + ws = @tester.words(num: 2..5) + ss = @tester.sentences(sentence_count: 2..5) + ps = @tester.paragraphs(paragraph_count: 2..5) assert(cs.length >= 2 && cs.length <= 5) assert(ws.length >= 2 && ws.length <= 5) @@ -75,10 +75,10 @@ def test_range_count_param end def test_exclusive_range_count_param - cs = @tester.characters(2...3) - ws = @tester.words(2...3) - ss = @tester.sentences(2...3) - ps = @tester.paragraphs(2...3) + cs = @tester.characters(char_count: 2...3) + ws = @tester.words(num: 2...3) + ss = @tester.sentences(sentence_count: 2...3) + ps = @tester.paragraphs(paragraph_count: 2...3) assert_equal(2, cs.length) assert_equal(2, ws.length) @@ -87,10 +87,10 @@ def test_exclusive_range_count_param end def test_array_count_param - cs = @tester.characters([1, 4]) - ws = @tester.words([1, 4]) - ss = @tester.sentences([1, 4]) - ps = @tester.paragraphs([1, 4]) + cs = @tester.characters(char_count: [1, 4]) + ws = @tester.words(num: [1, 4]) + ss = @tester.sentences(sentence_count: [1, 4]) + ps = @tester.paragraphs(paragraph_count: [1, 4]) assert(cs.length == 1 || cs.length == 4) assert(ws.length == 1 || ws.length == 4) @@ -99,9 +99,9 @@ def test_array_count_param end def test_words_with_large_count_params - exact = @tester.words(500) - range = @tester.words(250..500) - array = @tester.words([250, 500]) + exact = @tester.words(num: 500) + range = @tester.words(num: 250..500) + array = @tester.words(num: [250, 500]) assert(exact.length == 500) assert(range.length >= 250 && range.length <= 500) @@ -114,7 +114,7 @@ def test_multibyte end def test_paragraph_char_count - paragraph = @tester.paragraph_by_chars(256) + paragraph = @tester.paragraph_by_chars(chars: 256) assert(paragraph.length == 256) end diff --git a/test/faker/default/test_faker_lorem_flickr.rb b/test/faker/default/test_faker_lorem_flickr.rb index 283589ef71..5330f84bee 100644 --- a/test/faker/default/test_faker_lorem_flickr.rb +++ b/test/faker/default/test_faker_lorem_flickr.rb @@ -13,25 +13,25 @@ def test_image end def test_image_with_size - assert @tester.image('50x60') == 'http://loremflickr.com/50/60' + assert @tester.image(size: '50x60') == 'http://loremflickr.com/50/60' end def test_image_with_incorrect_size assert_raise ArgumentError do - @tester.image('300x300s') + @tester.image(size: '300x300s') end end def test_image_with_single_search_term - assert @tester.image('50x60', %w[faker]) == 'http://loremflickr.com/50/60/faker' + assert @tester.image(size: '50x60', search_terms: %w[faker]) == 'http://loremflickr.com/50/60/faker' end def test_image_with_multiple_search_terms - assert @tester.image('50x60', %w[dog cat]) == 'http://loremflickr.com/50/60/dog,cat' + assert @tester.image(size: '50x60', search_terms: %w[dog cat]) == 'http://loremflickr.com/50/60/dog,cat' end def test_image_with_search_terms_and_match_all - assert @tester.image('50x60', %w[dog cat], true) == 'http://loremflickr.com/50/60/dog,cat/all' + assert @tester.image(size: '50x60', search_terms: %w[dog cat], match_all: true) == 'http://loremflickr.com/50/60/dog,cat/all' end def test_grayscale_image @@ -40,24 +40,24 @@ def test_grayscale_image def test_grayscale_image_with_incorrect_size assert_raise ArgumentError do - @tester.grayscale_image('300x300s') + @tester.grayscale_image(size: '300x300s') end end def test_grayscale_image_without_search_terms - @tester.grayscale_image('50x60') == 'http://loremflickr.com/g/50/60/all' + @tester.grayscale_image(size: '50x60') == 'http://loremflickr.com/g/50/60/all' end def test_grayscale_image_with_single_search_term - assert @tester.grayscale_image('50x60', %w[faker]) == 'http://loremflickr.com/g/50/60/faker' + assert @tester.grayscale_image(size: '50x60', search_terms: %w[faker]) == 'http://loremflickr.com/g/50/60/faker' end def test_grayscale_image_with_multiple_search_terms - assert @tester.grayscale_image('50x60', %w[dog cat]) == 'http://loremflickr.com/g/50/60/dog,cat' + assert @tester.grayscale_image(size: '50x60', search_terms: %w[dog cat]) == 'http://loremflickr.com/g/50/60/dog,cat' end def test_grayscale_image_with_search_terms_and_match_all - assert @tester.grayscale_image('50x60', %w[dog cat], true) == 'http://loremflickr.com/g/50/60/dog,cat/all' + assert @tester.grayscale_image(size: '50x60', search_terms: %w[dog cat], match_all: true) == 'http://loremflickr.com/g/50/60/dog,cat/all' end def test_pixelated_image @@ -66,24 +66,24 @@ def test_pixelated_image def test_pixelated_image_with_incorrect_size assert_raise ArgumentError do - @tester.pixelated_image('300x300s') + @tester.pixelated_image(size: '300x300s') end end def test_pixelated_image_without_search_terms - @tester.pixelated_image('50x60') == 'http://loremflickr.com/p/50/60/all' + @tester.pixelated_image(size: '50x60') == 'http://loremflickr.com/p/50/60/all' end def test_pixelated_image_with_single_search_term - assert @tester.pixelated_image('50x60', %w[faker]) == 'http://loremflickr.com/p/50/60/faker' + assert @tester.pixelated_image(size: '50x60', search_terms: %w[faker]) == 'http://loremflickr.com/p/50/60/faker' end def test_pixelated_image_with_multiple_search_terms - assert @tester.pixelated_image('50x60', %w[dog cat]) == 'http://loremflickr.com/p/50/60/dog,cat' + assert @tester.pixelated_image(size: '50x60', search_terms: %w[dog cat]) == 'http://loremflickr.com/p/50/60/dog,cat' end def test_pixelated_image_with_search_terms_and_match_all - assert @tester.pixelated_image('50x60', %w[dog cat], true) == 'http://loremflickr.com/p/50/60/dog,cat/all' + assert @tester.pixelated_image(size: '50x60', search_terms: %w[dog cat], match_all: true) == 'http://loremflickr.com/p/50/60/dog,cat/all' end def test_colorized_image @@ -92,35 +92,35 @@ def test_colorized_image def test_colorized_image_with_incorrect_size assert_raise ArgumentError do - @tester.colorized_image('300x300s') + @tester.colorized_image(size: '300x300s') end end def test_colorized_image_without_search_terms - @tester.colorized_image('50x60', 'red') == 'http://loremflickr.com/red/50/60/all' + @tester.colorized_image(size: '50x60', color: 'red') == 'http://loremflickr.com/red/50/60/all' end def test_colorized_image_with_unsupported_colorization assert_raise ArgumentError do - @tester.colorized_image('50x60', 'yellow') + @tester.colorized_image(size: '50x60', color: 'yellow') end end def test_colorized_image_with_single_search_term @colorizations.each do |colorization| - assert @tester.colorized_image('50x60', colorization, %w[faker]) == "http://loremflickr.com/#{colorization}/50/60/faker" + assert @tester.colorized_image(size: '50x60', color: colorization, search_terms: %w[faker]) == "http://loremflickr.com/#{colorization}/50/60/faker" end end def test_colorized_image_with_multiple_search_terms @colorizations.each do |colorization| - assert @tester.colorized_image('50x60', colorization, %w[dog cat]) == "http://loremflickr.com/#{colorization}/50/60/dog,cat" + assert @tester.colorized_image(size: '50x60', color: colorization, search_terms: %w[dog cat]) == "http://loremflickr.com/#{colorization}/50/60/dog,cat" end end def test_colorized_image_with_search_terms_and_match_all @colorizations.each do |colorization| - assert @tester.colorized_image('50x60', colorization, %w[dog cat], true) == "http://loremflickr.com/#{colorization}/50/60/dog,cat/all" + assert @tester.colorized_image(size: '50x60', color: colorization, search_terms: %w[dog cat], match_all: true) == "http://loremflickr.com/#{colorization}/50/60/dog,cat/all" end end end diff --git a/test/faker/default/test_faker_name.rb b/test/faker/default/test_faker_name.rb index 44642b927c..055bdc6471 100644 --- a/test/faker/default/test_faker_name.rb +++ b/test/faker/default/test_faker_name.rb @@ -45,6 +45,6 @@ def test_suffix def test_initials assert @tester.initials.match(/[A-Z]{3}/) - assert @tester.initials(2).match(/[A-Z]{2}/) + assert @tester.initials(character_count: 2).match(/[A-Z]{2}/) end end diff --git a/test/faker/default/test_faker_national_health_service.rb b/test/faker/default/test_faker_national_health_service.rb index 3c09059d25..4d06310a02 100644 --- a/test/faker/default/test_faker_national_health_service.rb +++ b/test/faker/default/test_faker_national_health_service.rb @@ -18,10 +18,10 @@ def test_nhs_check_digit_equals_10 end def test_nhs_check_digit - assert_equal 6, @tester.check_digit(400_012_114) + assert_equal 6, @tester.check_digit(number: 400_012_114) end def test_nhs_check_digit_11 - assert_equal 0, @tester.check_digit(418_513_625) + assert_equal 0, @tester.check_digit(number: 418_513_625) end end diff --git a/test/faker/default/test_faker_number.rb b/test/faker/default/test_faker_number.rb index 1645595102..ba6af346e1 100644 --- a/test/faker/default/test_faker_number.rb +++ b/test/faker/default/test_faker_number.rb @@ -8,24 +8,26 @@ def setup @tester = Faker::Number end + def test_leading_zero_number + assert_match(/^0[0-9]{9}/, @tester.leading_zero_number) + assert_match(/^0[0-9]{8}/, @tester.leading_zero_number(digits: 9)) + end + def test_number - assert @tester.number(10).to_s.match(/[0-9]{10}/) + assert @tester.number(digits: 10).to_s.match(/[0-9]{10}/) 10.times do |digits| digits += 1 - assert @tester.number(digits).to_s.match(/^[0-9]{#{digits}}$/) + assert @tester.number(digits: digits).to_s.match(/^[0-9]{#{digits}}$/) end - assert @tester.number(10).to_s.length == 10 - assert @tester.number(1).to_s.length == 1 - assert @tester.number(0).nil? + assert @tester.number(digits: 10).to_s.length == 10 + assert @tester.number(digits: 1).to_s.length == 1 end def test_decimal - 100.times do - assert @tester.decimal(2).to_s.match(/[1-9][0-9]\.[0-9][1-9]/) - assert @tester.decimal(4, 5).to_s.match(/[1-9][0-9]{3}\.[0-9]{4}[1-9]/) - end + assert @tester.decimal(l_digits: 2).to_s.match(/[0-9]{2}\.[0-9]{2}/) + assert @tester.decimal(l_digits: 4, r_digits: 5).to_s.match(/[0-9]{4}\.[0-9]{5}/) end def test_digit @@ -50,7 +52,7 @@ def test_even_distribution def test_normal n = 10_000 - values = Array.new(n) { @tester.normal(150.0, 100.0) } + values = Array.new(n) { @tester.normal(mean: 150.0, standard_deviation: 100.0) } mean = values.reduce(:+) / n.to_f variance = values.inject(0) { |var, value| var + (value - mean)**2 } / (n - 1).to_f std_dev = Math.sqrt variance @@ -61,7 +63,7 @@ def test_normal def test_between 100.times do - random_number = @tester.between(-50, 50) + random_number = @tester.between(from: -50, to: 50) assert random_number >= -50, "Expected >= -50, but got #{random_number}" assert random_number <= 50, "Expected <= 50, but got #{random_number}" end @@ -69,7 +71,7 @@ def test_between def test_within 100.times do - random_number = @tester.within(-50..50) + random_number = @tester.within(range: -50..50) assert random_number >= -50, "Expected >= -50, but got #{random_number}" assert random_number <= 50, "Expected <= 50, but got #{random_number}" end @@ -77,7 +79,7 @@ def test_within def test_positive 100.times do - random_number = @tester.positive(1, 100) + random_number = @tester.positive(from: 1, to: 100) assert random_number >= 1, "Expected >= 1, but got #{random_number}" assert random_number <= 100, "Expected <= 100, but got #{random_number}" end @@ -85,45 +87,45 @@ def test_positive def test_negative 100.times do - random_number = @tester.negative(-1, -100) + random_number = @tester.negative(from: -1, to: -100) assert random_number <= -1, "Expected <= -1, but got #{random_number}" assert random_number >= -100, "Expected >= -100, but got #{random_number}" end end def test_force_positive - random_number = @tester.positive(-1, -100) + random_number = @tester.positive(from: -1, to: -100) assert random_number >= 1, "Expected >= 1, but got #{random_number}" assert random_number <= 100, "Expected <= 100, but got #{random_number}" end def test_force_negative - random_number = @tester.negative(1, 100) + random_number = @tester.negative(from: 1, to: 100) assert random_number <= -1, "Expected <= -1, but got #{random_number}" assert random_number >= -100, "Expected >= -100, but got #{random_number}" end def test_parameters_order - random_number = @tester.between(100, 1) + random_number = @tester.between(from: 100, to: 1) assert random_number >= 1, "Expected >= 1, but got #{random_number}" assert random_number <= 100, "Expected <= 100, but got #{random_number}" end def test_hexadecimal - assert @tester.hexadecimal(4).match(/[0-9a-f]{4}/) - assert @tester.hexadecimal(7).match(/[0-9a-f]{7}/) + assert @tester.hexadecimal(digits: 4).match(/[0-9a-f]{4}/) + assert @tester.hexadecimal(digits: 7).match(/[0-9a-f]{7}/) end def test_insignificant_zero @tester.stub :digit, 0 do - assert_equal 0, @tester.number(1) + assert_equal '0', @tester.number(digits: 1).to_s 100.times do - assert_match(/^[1-9]0/, @tester.number(2).to_s) + assert_match(/^[1-9]0/, @tester.number(digits: 2).to_s) end - assert_equal 0.0, @tester.decimal(1, 1) + assert_equal 0.0, @tester.decimal(l_digits: 1, r_digits: 1) 100.times do - assert_match(/^0\.[0-9]/, @tester.decimal(1, 2).to_s) + assert_match(/^0\.0[1-9]/, @tester.decimal(l_digits: 1, r_digits: 2).to_s) end end end diff --git a/test/faker/default/test_faker_relationship.rb b/test/faker/default/test_faker_relationship.rb index 9e04214623..8e5fe415b9 100644 --- a/test/faker/default/test_faker_relationship.rb +++ b/test/faker/default/test_faker_relationship.rb @@ -12,17 +12,17 @@ def test_random_familial end def test_familial_direct - assert @tester.familial('direct').match(/\w+/) + assert @tester.familial(connection: 'direct').match(/\w+/) end def test_familial_extended - assert @tester.familial('extended').match(/\w+/) + assert @tester.familial(connection: 'extended').match(/\w+/) end # test error on no match def test_invalid_familial_connection assert_raise ArgumentError do - @tester.familial('Not Correct') + @tester.familial(connection: 'Not Correct') end end diff --git a/test/faker/default/test_faker_source.rb b/test/faker/default/test_faker_source.rb index a4a213fc5a..6c296d21d2 100644 --- a/test/faker/default/test_faker_source.rb +++ b/test/faker/default/test_faker_source.rb @@ -36,6 +36,6 @@ def test_print_1_to_10_instance end def test_print_1_to_10_javascript - assert_match 'console.log(i);', @tester.print_1_to_10(:javascript) + assert_match 'console.log(i);', @tester.print_1_to_10(lang: :javascript) end end diff --git a/test/faker/default/test_faker_street.rb b/test/faker/default/test_faker_street.rb index 63bbf7db4a..04a33e78d1 100644 --- a/test/faker/default/test_faker_street.rb +++ b/test/faker/default/test_faker_street.rb @@ -52,7 +52,7 @@ def test_community_supports_flexible_formats def test_street_address_optionally_provides_secondary_address I18n.with_locale(:shire) do - assert_match(/Wide Cheerful Path \d \(Green Door\)/, @tester.street_address(:include_secondary)) + assert_match(/Wide Cheerful Path \d \(Green Door\)/, @tester.street_address(include_secondary: true)) end end diff --git a/test/faker/default/test_faker_string.rb b/test/faker/default/test_faker_string.rb index 47a608bcf2..9520485514 100644 --- a/test/faker/default/test_faker_string.rb +++ b/test/faker/default/test_faker_string.rb @@ -17,7 +17,7 @@ def test_is_string def test_has_valid_encoding assert @tester.random.valid_encoding? - 128.times { assert @tester.random(1..128).valid_encoding? } + 128.times { assert @tester.random(length: 1..128).valid_encoding? } end def test_is_utf8 @@ -29,35 +29,35 @@ def test_default_length end def test_nil_is_zero - 2.times { assert @tester.random(nil).empty? } + 2.times { assert @tester.random(length: nil).empty? } end def test_int_length [0, -1, 1, rand(500), rand(-2048..2047)].each do |len| - 8.times { assert @tester.random(len).length == [0, len].max } + 8.times { assert @tester.random(length: len).length == [0, len].max } end end def test_range_length range = (-5..30) - 16.times { assert range.include? @tester.random(range).length } + 16.times { assert range.include? @tester.random(length: range).length } range = (42..42) - assert @tester.random(range).length == 42 + assert @tester.random(length: range).length == 42 end def test_array_length array = [0, -1, 1, 1024, rand(2048)] - 8.times { assert array.include? @tester.random(array).length } + 8.times { assert array.include? @tester.random(length: array).length } num = rand(-2048..2047) array = [num, num, num] - 8.times { assert @tester.random(array).length == [0, num].max } + 8.times { assert @tester.random(length: array).length == [0, num].max } end def test_nested_lengths test = lambda do - @tester.random([1, (2..5), [3, (-7...6)], nil]) + @tester.random(length: [1, (2..5), [3, (-7...6)], nil]) end 16.times { assert(((0..5).cover? test.call.length)) } end diff --git a/test/faker/default/test_faker_stripe.rb b/test/faker/default/test_faker_stripe.rb index cddedeb70c..0d8f312492 100644 --- a/test/faker/default/test_faker_stripe.rb +++ b/test/faker/default/test_faker_stripe.rb @@ -18,7 +18,7 @@ def test_valid_card_error end def test_specific_valid_card - assert @tester.valid_card('visa').match(/\A\d{16}\z/) + assert @tester.valid_card(card_type: 'visa').match(/\A\d{16}\z/) end def test_valid_token @@ -26,7 +26,7 @@ def test_valid_token end def test_specific_valid_token - assert @tester.valid_token('visa').match(/\Atok_visa\z/) + assert @tester.valid_token(card_type: 'visa').match(/\Atok_visa\z/) end def test_invalid_card @@ -40,7 +40,7 @@ def test_invalid_card_error end def test_specific_error_invalid_card - assert @tester.invalid_card('zipFail').match(/\w+/) + assert @tester.invalid_card(card_error: 'zipFail').match(/\w+/) end def test_valid_exp_mo @@ -56,6 +56,6 @@ def test_valid_ccv end def test_valid_amex_ccv - assert @tester.ccv('amex').match(/\A\d{4}\z/) + assert @tester.ccv(card_type: 'amex').match(/\A\d{4}\z/) end end diff --git a/test/faker/default/test_faker_time.rb b/test/faker/default/test_faker_time.rb index 66fc68af86..d869075b85 100644 --- a/test/faker/default/test_faker_time.rb +++ b/test/faker/default/test_faker_time.rb @@ -36,7 +36,7 @@ def test_forward today = Date.today 100.times do - random_time = @tester.forward(10) + random_time = @tester.forward(days: 10) assert random_time > today.to_time, "Expected > \"#{today}\", but got #{random_time}" end end @@ -45,7 +45,7 @@ def test_backward tomorrow = Date.today + 1 100.times do - random_time = @tester.backward(10) + random_time = @tester.backward(days: 10) assert random_time < tomorrow.to_time, "Expected < \"#{tomorrow}\", but got #{random_time}" end end @@ -60,10 +60,10 @@ def test_invalid_period_error end def test_return_type - random_backward = @tester.backward(5) + random_backward = @tester.backward(days: 5) random_between_dates = @tester.between(Date.today, Date.today + 5) random_between_times = @tester.between(Time.now, Time.now + TEN_HOURS) - random_forward = @tester.forward(5) + random_forward = @tester.forward(days: 5) [ random_backward, @@ -82,9 +82,9 @@ def test_format 100.times do period = @time_ranges.keys.to_a.sample - random_backward = @tester.backward(30, period, format) - random_between = @tester.between(from, to, period, format) - random_forward = @tester.forward(30, period, format) + random_backward = @tester.backward(days: 30, period: period, format: format) + random_between = @tester.between(from, to, period: period, format: format) + random_forward = @tester.forward(days: 30, period: period, format: format) [random_backward, random_between, random_forward].each do |result| assert result.is_a?(String), "Expected a String, but got #{result.class}" assert_nothing_raised 'Not a valid date string' do @@ -104,9 +104,9 @@ def test_time_period period = @time_ranges.keys.to_a.sample period_range = @time_ranges[period] - random_backward = @tester.backward(30, period) - random_between = @tester.between(from, to, period) - random_forward = @tester.forward(30, period) + random_backward = @tester.backward(days: 30, period: period) + random_between = @tester.between(from, to, period: period) + random_forward = @tester.forward(days: 30, period: period) [random_backward, random_between, random_forward].each_with_index do |result, index| assert period_range.include?(result.hour.to_i), "#{%i[random_backward random_between random_forward][index]}: \"#{result}\" expected to be included in Faker::Time::TIME_RANGES[:#{period}] range" @@ -118,7 +118,7 @@ def test_time_period 100.times do period = :between - random_between = @tester.between(from, to, period) + random_between = @tester.between(from, to, period: period) assert random_between >= from, "Expected >= \"#{from}\", but got #{random_between}" assert random_between <= to, "Expected <= \"#{to}\", but got #{random_between}" end diff --git a/test/faker/default/test_faker_types.rb b/test/faker/default/test_faker_types.rb index a11363eb82..c85ff02598 100644 --- a/test/faker/default/test_faker_types.rb +++ b/test/faker/default/test_faker_types.rb @@ -15,9 +15,9 @@ def test_rb_string_is_or_correct_type end def test_string_returns_correct_number_of_words - assert @tester.rb_string(1).split(' ').length == 1 - assert @tester.rb_string(5).split(' ').length == 5 - assert @tester.rb_string(0).split(' ').empty? + assert @tester.rb_string(words: 1).split(' ').length == 1 + assert @tester.rb_string(words: 5).split(' ').length == 5 + assert @tester.rb_string(words: 0).split(' ').empty? end def test_character @@ -35,7 +35,7 @@ def test_integer def test_rb_integer_between from = Faker::Number.number.to_i to = from + Faker::Number.number.to_i - val = @tester.rb_integer(from, to) + val = @tester.rb_integer(from: from, to: to) assert val < to && val >= from end @@ -44,8 +44,8 @@ def test_rb_hash_returns_a_hash end def test_hash_returns_the_correct_number_of_keys - assert @tester.rb_hash(3).keys.length == 3 - assert @tester.rb_hash(0).keys.empty? + assert @tester.rb_hash(key_count: 3).keys.length == 3 + assert @tester.rb_hash(key_count: 0).keys.empty? assert @tester.rb_hash.keys.length == 1 end @@ -54,8 +54,8 @@ def test_complex_rb_hash_returns_a_hash end def test_complex_hash_returns_the_correct_number_of_keys - assert @tester.complex_rb_hash(3).keys.length == 3 - assert @tester.complex_rb_hash(0).keys.empty? + assert @tester.complex_rb_hash(key_count: 3).keys.length == 3 + assert @tester.complex_rb_hash(key_count: 0).keys.empty? assert @tester.complex_rb_hash.keys.length == 1 end @@ -64,8 +64,8 @@ def test_rb_array_returns_array end def test_array_has_the_right_array - assert @tester.rb_array(3).length == 3 - assert @tester.rb_array(0).empty? + assert @tester.rb_array(len: 3).length == 3 + assert @tester.rb_array(len: 0).empty? assert @tester.rb_array.length == 1 end diff --git a/test/faker/default/test_faker_vehicle.rb b/test/faker/default/test_faker_vehicle.rb index 792a38479b..695e852453 100644 --- a/test/faker/default/test_faker_vehicle.rb +++ b/test/faker/default/test_faker_vehicle.rb @@ -56,7 +56,7 @@ def test_engine end def test_mileage - mileage = @tester.mileage(5, 10) + mileage = @tester.mileage(min: 5, max: 10) assert mileage >= 5 && mileage <= 10 end @@ -66,7 +66,7 @@ def test_license_plate end def test_license_plate_with_params - assert_match WORD_MATCH, @tester.license_plate('CA') + assert_match WORD_MATCH, @tester.license_plate(state_abreviation: 'CA') end def test_make @@ -78,7 +78,7 @@ def test_model end def test_model_with_make - assert_match WORD_MATCH, @tester.model('Toyota') + assert_match WORD_MATCH, @tester.model(make_of_model: 'Toyota') end def test_make_and_model diff --git a/test/faker/default/test_faker_zip_code.rb b/test/faker/default/test_faker_zip_code.rb index 6edf6d05d7..cd386e5f0b 100644 --- a/test/faker/default/test_faker_zip_code.rb +++ b/test/faker/default/test_faker_zip_code.rb @@ -58,7 +58,7 @@ def test_zip_codes_with_states I18n.with_locale(:xz) do zip_codes = @zip_codes_with_state 100.times do - zip_code = @tester.zip_code('NY') + zip_code = @tester.zip_code(state_abbreviation: 'NY') assert zip_codes.include?(zip_code), "Expected <#{zip_codes.join(' / ')}>, but got #{zip_code}" end end diff --git a/test/faker/default/test_invoice.rb b/test/faker/default/test_invoice.rb index 92da3190f6..023603a768 100644 --- a/test/faker/default/test_invoice.rb +++ b/test/faker/default/test_invoice.rb @@ -12,7 +12,7 @@ def test_amount_between to = 1000.0 100.times do - random_amount = @tester.amount_between(from, to) + random_amount = @tester.amount_between(from: from, to: to) assert random_amount >= from, "Expected >= \"#{from}\", but got #{random_amount}" assert random_amount <= to, "Expected <= \"#{to}\", but got #{random_amount}" end @@ -31,7 +31,7 @@ def test_reference end def test_reference_checksum - reference = @tester.reference('515141803475128#') + reference = @tester.reference(ref: '515141803475128#') assert reference == '5151418034751285' end diff --git a/test/faker/default/test_lorem_pixel.rb b/test/faker/default/test_lorem_pixel.rb index 32b9b62c6f..bc871fd261 100644 --- a/test/faker/default/test_lorem_pixel.rb +++ b/test/faker/default/test_lorem_pixel.rb @@ -12,60 +12,60 @@ def test_lorempixel end def test_lorempixel_insecure - assert !@tester.image('300x300', nil, nil, nil, nil, secure: false).match(%r{http:\/\/lorempixel\.com\/(\d+\/\d+)})[1].nil? + assert !@tester.image(size: '300x300', is_gray: nil, category: nil, number: nil, text: nil, secure: false).match(%r{http:\/\/lorempixel\.com\/(\d+\/\d+)})[1].nil? end def test_image_with_custom_size - assert @tester.image('3x3').match(%r{https:\/\/lorempixel\.com\/(\d+\/\d+)})[1] == '3/3' + assert @tester.image(size: '3x3').match(%r{https:\/\/lorempixel\.com\/(\d+\/\d+)})[1] == '3/3' end def test_image_with_incorrect_size assert_raise ArgumentError do - @tester.image('300x300s') + @tester.image(size: '300x300s') end end def test_image_gray - assert @tester.image('300x300', true).match(%r{https:\/\/lorempixel\.com\/g\/\d+\/\d+}) + assert @tester.image(size: '300x300', is_gray: true).match(%r{https:\/\/lorempixel\.com\/g\/\d+\/\d+}) end def test_image_with_supported_category - assert @tester.image('300x300', false, 'animals').match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/(.*)})[1] == 'animals' + assert @tester.image(size: '300x300', is_gray: false, category: 'animals').match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/(.*)})[1] == 'animals' end def test_image_with_incorrect_category assert_raise ArgumentError do - @tester.image('300x300', false, 'wrong_category') + @tester.image(size: '300x300', is_gray: false, category: 'wrong_category') end end def test_image_with_supported_category_and_correct_number - assert @tester.image('300x300', false, 'animals', 3).match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/.+\/(\d+)})[1] == '3' + assert @tester.image(size: '300x300', is_gray: false, category: 'animals', number: 3).match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/.+\/(\d+)})[1] == '3' end def test_image_with_supported_category_and_incorrect_number assert_raise ArgumentError do - @tester.image('300x300', false, 'animals', 11) + @tester.image(size: '300x300', is_gray: false, category: 'animals', number: 11) end end def test_image_with_correct_number_and_without_category assert_raise ArgumentError do - @tester.image('300x300', false, 'wrong_category', 3) + @tester.image(size: '300x300', is_gray: false, category: 'wrong_category', number: 3) end end def test_image_with_text_correct_number_and_supported_category - assert @tester.image('300x300', false, 'animals', 3, 'Dummy-text').match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/.+\/3\/(.+)})[1] == 'Dummy-text' + assert @tester.image(size: '300x300', is_gray: false, category: 'animals', number: 3, text: 'Dummy-text').match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/.+\/3\/(.+)})[1] == 'Dummy-text' end def test_image_with_text_supported_category_and_text_without_number - assert @tester.image('300x300', false, 'animals', nil, 'Dummy-text').match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/.+\/(.+)})[1] == 'Dummy-text' + assert @tester.image(size: '300x300', is_gray: false, category: 'animals', number: nil, text: 'Dummy-text').match(%r{https:\/\/lorempixel\.com\/\d+\/\d+\/.+\/(.+)})[1] == 'Dummy-text' end def test_image_with_text_without_number_and_category assert_raise ArgumentError do - @tester.image('300x300', false, nil, nil, 'Dummy-text') + @tester.image(size: '300x300', is_gray: false, category: nil, number: nil, text: 'Dummy-text') end end end diff --git a/test/faker/default/test_placeholdit.rb b/test/faker/default/test_placeholdit.rb index 2840cdc554..cf36811477 100644 --- a/test/faker/default/test_placeholdit.rb +++ b/test/faker/default/test_placeholdit.rb @@ -12,90 +12,90 @@ def test_placeholdit end def test_avatar_with_custom_size - assert @tester.image('3x3').match(%r{https:\/\/placehold\.it\/+(\d+x\d+)})[1] == '3x3' + assert @tester.image(size: '3x3').match(%r{https:\/\/placehold\.it\/+(\d+x\d+)})[1] == '3x3' end def test_avatar_with_incorrect_size assert_raise ArgumentError do - @tester.image('300x300s') + @tester.image(size: '300x300s') end end def test_avatar_with_supported_format - assert @tester.image('300x300', 'jpg').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)}) + assert @tester.image(size: '300x300', format: 'jpg').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)}) end def test_avatar_with_incorrect_format assert_raise ArgumentError do - @tester.image('300x300', 'wrong_format') + @tester.image(size: '300x300', format: 'wrong_format') end end def test_avatar_background_with_correct_six_char_hex - assert @tester.image('300x300', 'jpg', 'ffffff').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/ffffff}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/ffffff}) end def test_avatar_background_with_correct_three_char_hex - assert @tester.image('300x300', 'jpg', 'fff').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/fff}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: 'fff').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/fff}) end def test_avatar_background_with_random_color - assert @tester.image('300x300', 'jpg', :random).match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/[a-f0-9]{6}}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: :random).match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/[a-f0-9]{6}}) end def test_avatar_background_with_wrong_six_char_hex assert_raise ArgumentError do - @tester.image('300x300', 'jpg', 'fffffz') + @tester.image(size: '300x300', format: 'jpg', background_color: 'fffffz') end end def test_avatar_background_with_wrong_hex assert_raise ArgumentError do - @tester.image('300x300', 'jpg', 'ffff4') + @tester.image(size: '300x300', format: 'jpg', background_color: 'ffff4') end end def test_avatar_background_with_wrong_three_char_hex assert_raise ArgumentError do - @tester.image('300x300', 'jpg', 'ffz') + @tester.image(size: '300x300', format: 'jpg', background_color: 'ffz') end end def test_avatar_font_color_with_correct_six_char_hex - assert @tester.image('300x300', 'jpg', 'ffffff', '000000').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/ffffff\/000000}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff', text_color: '000000').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/ffffff\/000000}) end def test_avatar_font_color_with_correct_three_char_hex - assert @tester.image('300x300', 'jpg', 'fff', '000').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/fff}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000').match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/fff}) end def test_avatar_font_color_with_random_color - assert @tester.image('300x300', 'jpg', 'fff', :random).match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/fff\/[a-f0-9]{6}}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: :random).match(%r{https:\/\/placehold\.it\/(.+)(jpg?)\/fff\/[a-f0-9]{6}}) end def test_avatar_font_color_with_wrong_six_char_hex assert_raise ArgumentError do - @tester.image('300x300', 'jpg', 'ffffff', '900F0z') + @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff', text_color: '900F0z') end end def test_avatar_font_color_with_wrong_hex assert_raise ArgumentError do - @tester.image('300x300', 'jpg', 'ffffff', 'x9') + @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff', text_color: 'x9') end end def test_avatar_font_color_with_wrong_three_char_hex assert_raise ArgumentError do - @tester.image('300x300', 'jpg', 'ffffff', '00p') + @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff', text_color: '00p') end end def test_text_not_present - assert @tester.image('300x300', 'jpg', 'fff', '000').match(%r{https:\/\/placehold\.it\/[^\\?]+$}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000').match(%r{https:\/\/placehold\.it\/[^\\?]+$}) end def test_text_present - assert @tester.image('300x300', 'jpg', 'fff', '000', 'hello').match(%r{https:\/\/placehold\.it\/(.+)\?text=hello}) + assert @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000', text: 'hello').match(%r{https:\/\/placehold\.it\/(.+)\?text=hello}) end end diff --git a/test/faker/movies/test_faker_star_wars.rb b/test/faker/movies/test_faker_star_wars.rb index 3551f7065f..eebef928ab 100644 --- a/test/faker/movies/test_faker_star_wars.rb +++ b/test/faker/movies/test_faker_star_wars.rb @@ -29,18 +29,18 @@ def test_quote # test good match def test_random_character_quote - assert @tester.quote('admiral_ackbar').match(/\w+/) + assert @tester.quote(character: 'admiral_ackbar').match(/\w+/) end # test good alternate spelling match def test_random_character_alt_spelling_quote - assert @tester.quote('ackbar').match(/\w+/) + assert @tester.quote(character: 'ackbar').match(/\w+/) end # test error on no match def test_invalid_quote assert_raise ArgumentError do - @tester.quote('Leto Atreides') + @tester.quote(character: 'Leto Atreides') end end diff --git a/test/test_ee_locale.rb b/test/test_ee_locale.rb index c8834fec3c..6eb34831f6 100644 --- a/test/test_ee_locale.rb +++ b/test/test_ee_locale.rb @@ -42,7 +42,7 @@ def test_ee_internet_methods def test_ee_invoice_methods assert Faker::Invoice.creditor_reference.is_a? String assert Faker::Invoice.reference.is_a? String - assert Faker::Invoice.reference('4106453482608858924').is_a? String + assert Faker::Invoice.reference(ref: '4106453482608858924').is_a? String end def test_ee_name_methods diff --git a/test/test_en_ca_locale.rb b/test/test_en_ca_locale.rb index 7c5b5d4fab..8a399d4a6c 100644 --- a/test/test_en_ca_locale.rb +++ b/test/test_en_ca_locale.rb @@ -31,7 +31,7 @@ def test_en_ca_internet_methods def test_en_ca_subscriber_number_method assert Faker::PhoneNumber.subscriber_number.is_a? String assert_equal Faker::PhoneNumber.subscriber_number.length, 4 - assert_equal Faker::PhoneNumber.subscriber_number(10).length, 10 + assert_equal Faker::PhoneNumber.subscriber_number(length: 10).length, 10 assert_equal Faker::PhoneNumber.method(:extension), Faker::PhoneNumber.method(:subscriber_number) end diff --git a/test/test_en_us_locale.rb b/test/test_en_us_locale.rb index 807b361b8e..140ae93f12 100644 --- a/test/test_en_us_locale.rb +++ b/test/test_en_us_locale.rb @@ -32,7 +32,7 @@ def test_en_us_phone_methods_return_nil_for_nil_locale def test_en_us_subscriber_number_method assert Faker::PhoneNumber.subscriber_number.is_a? String assert_equal Faker::PhoneNumber.subscriber_number.length, 4 - assert_equal Faker::PhoneNumber.subscriber_number(10).length, 10 + assert_equal Faker::PhoneNumber.subscriber_number(length: 10).length, 10 assert_equal Faker::PhoneNumber.method(:extension), Faker::PhoneNumber.method(:subscriber_number) end @@ -53,34 +53,34 @@ def test_validity_of_phone_method_output end def test_en_us_invalid_state_raises_exception - assert_raise(I18n::MissingTranslationData) { Faker::Address.zip_code('NA') } + assert_raise(I18n::MissingTranslationData) { Faker::Address.zip_code(state_abbreviation: 'NA') } end def test_en_us_zip_codes_match_state state_abbr = 'AZ' expected = /^850\d\d$/ - assert_match(expected, Faker::Address.zip_code(state_abbr)) + assert_match(expected, Faker::Address.zip_code(state_abbreviation: state_abbr)) # disjointed ranges for these states # http://www.fincen.gov/forms/files/us_state_territory_zip_codes.pdf state_abbr = 'AR' expected = /^717\d\d$/ - assert_match(expected, Faker::Address.zip_code(state_abbr)) + assert_match(expected, Faker::Address.zip_code(state_abbreviation: state_abbr)) state_abbr = 'GA' expected = /^301\d\d$/ - assert_match(expected, Faker::Address.zip_code(state_abbr)) + assert_match(expected, Faker::Address.zip_code(state_abbreviation: state_abbr)) state_abbr = 'MA' expected = /^026\d\d$/ - assert_match(expected, Faker::Address.zip_code(state_abbr)) + assert_match(expected, Faker::Address.zip_code(state_abbreviation: state_abbr)) state_abbr = 'NY' expected = /^122\d\d$/ - assert_match(expected, Faker::Address.zip_code(state_abbr)) + assert_match(expected, Faker::Address.zip_code(state_abbreviation: state_abbr)) state_abbr = 'TX' expected = /^798\d\d$/ - assert_match(expected, Faker::Address.zip_code(state_abbr)) + assert_match(expected, Faker::Address.zip_code(state_abbreviation: state_abbr)) state_abbr = 'VA' expected = /^222\d\d$/ - assert_match(expected, Faker::Address.zip_code(state_abbr)) + assert_match(expected, Faker::Address.zip_code(state_abbreviation: state_abbr)) end def test_en_us_valid_id_number diff --git a/test/test_es_locale.rb b/test/test_es_locale.rb index 5a211db3a1..b3394a7272 100644 --- a/test/test_es_locale.rb +++ b/test/test_es_locale.rb @@ -86,7 +86,7 @@ def test_es_name_methods assert Faker::Name.female_first_name.is_a? String assert Faker::Name.name.is_a? String assert Faker::Name.initials.match(/[A-Z]{3}/) - assert Faker::Name.initials(2).match(/[A-Z]{2}/) + assert Faker::Name.initials(character_count: 2).match(/[A-Z]{2}/) end def test_es_vehicle_methods diff --git a/test/test_es_mx_locale.rb b/test/test_es_mx_locale.rb index 50782069a4..34ce9c589d 100644 --- a/test/test_es_mx_locale.rb +++ b/test/test_es_mx_locale.rb @@ -21,8 +21,8 @@ def test_es_mx_address assert Faker::Address.city_prefix.empty? assert Faker::Address.city_suffix.empty? assert Faker::Address.city.is_a?(String) - assert Faker::Address.city(with_state: true).is_a?(String) - assert Faker::Address.city(with_state: true).split(', ').count == 2 + assert Faker::Address.city(options: { with_state: true }).is_a?(String) + assert Faker::Address.city(options: { with_state: true }).split(', ').count == 2 assert Faker::Address.secondary_address.is_a? String end diff --git a/test/test_fi_locale.rb b/test/test_fi_locale.rb index 605e543175..a72b0a3287 100644 --- a/test/test_fi_locale.rb +++ b/test/test_fi_locale.rb @@ -36,8 +36,8 @@ def test_fi_name_methods def test_fi_invoice_methods assert Faker::Invoice.creditor_reference.is_a? String assert Faker::Invoice.reference.is_a? String - assert Faker::Invoice.reference('515141803475128').is_a? String - assert Faker::Invoice.reference('515141803475128#') == '5151418034751285' + assert Faker::Invoice.reference(ref: '515141803475128').is_a? String + assert Faker::Invoice.reference(ref: '515141803475128#') == '5151418034751285' end def test_fi_phone_number diff --git a/test/test_fr_ca_locale.rb b/test/test_fr_ca_locale.rb index 6c4901e37c..1afdc2ec49 100644 --- a/test/test_fr_ca_locale.rb +++ b/test/test_fr_ca_locale.rb @@ -54,8 +54,8 @@ def test_fr_ca_internet_methods def test_fr_ca_lorem_methods assert Faker::Lorem.word.is_a? String - assert Faker::Lorem.words(1000) - assert Faker::Lorem.words(10_000, true) + assert Faker::Lorem.words(num: 1000) + assert Faker::Lorem.words(num: 10_000, supplemental: true) end def test_fr_ca_name_methods diff --git a/test/test_fr_ch_locale.rb b/test/test_fr_ch_locale.rb index f0ed32c2ae..78b3565bd8 100644 --- a/test/test_fr_ch_locale.rb +++ b/test/test_fr_ch_locale.rb @@ -51,8 +51,8 @@ def test_fr_ch_internet_methods def test_fr_ch_lorem_methods assert Faker::Lorem.word.is_a? String - assert Faker::Lorem.words(1000) - assert Faker::Lorem.words(10_000, true) + assert Faker::Lorem.words(num: 1000) + assert Faker::Lorem.words(num: 10_000, supplemental: true) end def test_fr_ch_name_methods diff --git a/test/test_fr_locale.rb b/test/test_fr_locale.rb index 1aef59dccb..a2a1336497 100644 --- a/test/test_fr_locale.rb +++ b/test/test_fr_locale.rb @@ -87,8 +87,8 @@ def test_fr_gender_methods def test_fr_lorem_methods assert Faker::Lorem.word.is_a? String - assert Faker::Lorem.words(1000) - assert Faker::Lorem.words(10_000, true) + assert Faker::Lorem.words(num: 1000) + assert Faker::Lorem.words(num: 10_000, supplemental: true) end def test_fr_measurement_methods diff --git a/test/test_hy_locale.rb b/test/test_hy_locale.rb index 4a6e651b8e..f01e1afd31 100644 --- a/test/test_hy_locale.rb +++ b/test/test_hy_locale.rb @@ -24,16 +24,16 @@ def test_hy_address_methods assert_kind_of String, Faker::Address.village assert_equal 'գ.', Faker::Address.village_prefix assert Faker::Address.zip_code.start_with?('0', '1', '2', '3', '4') - assert Faker::Address.zip('ԱԳ').start_with?('02', '03', '04', '05') - assert Faker::Address.zip('ԱՐ').start_with?('06', '07', '08') - assert Faker::Address.zip('ԱՄ').start_with?('09', '10', '11') - assert Faker::Address.zip('ԳՂ').start_with?('12', '13', '14', '15', '16') - assert Faker::Address.zip('ԼՌ').start_with?('17', '18', '19', '20', '21') - assert Faker::Address.zip('ԿՏ').start_with?('22', '23', '24', '25') - assert Faker::Address.zip('ՇԿ').start_with?('26', '27', '28', '29', '30', '31') - assert Faker::Address.zip('ՍՅ').start_with?('32', '33', '34', '35') - assert Faker::Address.zip('ՎՁ').start_with?('36', '37', '38') - assert Faker::Address.zip('ՏՎ').start_with?('39', '40', '41', '42') + assert Faker::Address.zip(state_abbreviation: 'ԱԳ').start_with?('02', '03', '04', '05') + assert Faker::Address.zip(state_abbreviation: 'ԱՐ').start_with?('06', '07', '08') + assert Faker::Address.zip(state_abbreviation: 'ԱՄ').start_with?('09', '10', '11') + assert Faker::Address.zip(state_abbreviation: 'ԳՂ').start_with?('12', '13', '14', '15', '16') + assert Faker::Address.zip(state_abbreviation: 'ԼՌ').start_with?('17', '18', '19', '20', '21') + assert Faker::Address.zip(state_abbreviation: 'ԿՏ').start_with?('22', '23', '24', '25') + assert Faker::Address.zip(state_abbreviation: 'ՇԿ').start_with?('26', '27', '28', '29', '30', '31') + assert Faker::Address.zip(state_abbreviation: 'ՍՅ').start_with?('32', '33', '34', '35') + assert Faker::Address.zip(state_abbreviation: 'ՎՁ').start_with?('36', '37', '38') + assert Faker::Address.zip(state_abbreviation: 'ՏՎ').start_with?('39', '40', '41', '42') assert_kind_of String, Faker::Address.street_name assert_kind_of String, Faker::Address.street_address assert_includes %w[փողոց պողոտա], Faker::Address.street_suffix diff --git a/test/test_ja_locale.rb b/test/test_ja_locale.rb index 987438c6b6..67eb7f8678 100644 --- a/test/test_ja_locale.rb +++ b/test/test_ja_locale.rb @@ -57,8 +57,8 @@ def test_ja_gender_methods def test_ja_lorem_methods assert Faker::Lorem.words.is_a? Array - assert Faker::Lorem.words(1000) - assert Faker::Lorem.words(10_000, true) + assert Faker::Lorem.words(num: 1000) + assert Faker::Lorem.words(num: 10_000, supplemental: true) end def test_ja_name_methods diff --git a/test/test_no_no_locale.rb b/test/test_no_no_locale.rb index 7542d04730..b41ca68171 100644 --- a/test/test_no_no_locale.rb +++ b/test/test_no_no_locale.rb @@ -24,7 +24,7 @@ def test_no_no_name_methods def test_no_no_invoice_methods assert Faker::Invoice.creditor_reference.is_a? String assert Faker::Invoice.reference.is_a? String - assert Faker::Invoice.reference('699027016279494093882102#').is_a? String - assert Faker::Invoice.reference('699027016279494093882102#') == '6990270162794940938821025' + assert Faker::Invoice.reference(ref: '699027016279494093882102#').is_a? String + assert Faker::Invoice.reference(ref: '699027016279494093882102#') == '6990270162794940938821025' end end diff --git a/test/test_pt_br_locale.rb b/test/test_pt_br_locale.rb index 2a4bad5a65..39eb8477fe 100644 --- a/test/test_pt_br_locale.rb +++ b/test/test_pt_br_locale.rb @@ -109,7 +109,7 @@ def test_pt_br_name_methods assert Faker::Name.female_first_name.is_a? String assert Faker::Name.name.is_a? String assert Faker::Name.initials.match(/[A-Z]{3}/) - assert Faker::Name.initials(2).match(/[A-Z]{2}/) + assert Faker::Name.initials(character_count: 2).match(/[A-Z]{2}/) end def test_pt_br_team_methods @@ -131,8 +131,8 @@ def test_pt_br_vehicle_methods assert Faker::Vehicle.license_plate.is_a? String assert Faker::Vehicle.license_plate.match(/^[A-Z]{3}\-[0-9]{4}/) - assert Faker::Vehicle.license_plate('RJ').is_a? String - assert Faker::Vehicle.license_plate('RJ').match(/^[A-Z]{3}\-[0-9]{4}/) + assert Faker::Vehicle.license_plate(state_abreviation: 'RJ').is_a? String + assert Faker::Vehicle.license_plate(state_abreviation: 'RJ').match(/^[A-Z]{3}\-[0-9]{4}/) end def test_pt_br_gender_methods diff --git a/test/test_seeding.rb b/test/test_seeding.rb index 03f9843962..e2d91f0e4f 100644 --- a/test/test_seeding.rb +++ b/test/test_seeding.rb @@ -7,12 +7,12 @@ def setup; end def test_deterministic Faker::Config.random = Random.new(5) - first_random = Faker::Number.number(100_000) + first_random = Faker::Number.number(digits: 100_000) Faker::Config.random = Random.new(5) - second_random = Faker::Number.number(100_000) + second_random = Faker::Number.number(digits: 100_000) Faker::Config.random = Random.new Faker::Config.random = nil - third_random = Faker::Number.number(100_000) + third_random = Faker::Number.number(digits: 100_000) assert first_random == second_random # Tiny chance this will fail randomly if the unseeded Random just so