1
0
mirror of https://github.com/askn/faker.git synced 2023-08-10 21:13:01 +03:00

Merge pull request #6 from rickychilcott/fix/specs

Fix Specs
This commit is contained in:
Aşkın Gedik 2018-09-21 16:30:59 +03:00 committed by GitHub
commit 68316d43a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 108 additions and 113 deletions

3
.gitignore vendored
View File

@ -2,9 +2,8 @@
/libs/
/.crystal/
/.shards/
.DS_Store
# Libraries don't need dependency lock
# Dependencies will be locked in application that uses them
/shard.lock

View File

@ -3,22 +3,22 @@ require "./spec_helper"
describe Faker::Address do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Address.city.should eq "North Mercedesmouth"
Faker::Address.street_name.should eq "Thalia Tunnel"
Faker::Address.street_address.should eq "33421 Kunde Mills"
Faker::Address.secondary_address.should eq "Apt. 475"
Faker::Address.building_number.should eq "4103"
Faker::Address.zip_code.should eq "32555"
Faker::Address.postcode.should eq "GX44 3IC"
Faker::Address.time_zone.should eq "Asia/Rangoon"
Faker::Address.street_suffix.should eq "Springs"
Faker::Address.city_suffix.should eq "town"
Faker::Address.city_prefix.should eq "North"
Faker::Address.state.should eq "Missouri"
Faker::Address.state_abbr.should eq "TN"
Faker::Address.country.should eq "Svalbard & Jan Mayen Islands"
Faker::Address.country_code.should eq "IS"
Faker::Address.latitude.should eq "15.393888556377334"
Faker::Address.longitude.should eq "-77.86301819889268"
Faker::Address.city.should eq "Kemmerland"
Faker::Address.street_name.should eq "Boyer Views"
Faker::Address.street_address.should eq "82059 Batz Passage"
Faker::Address.secondary_address.should eq "Apt. 856"
Faker::Address.building_number.should eq "22820"
Faker::Address.zip_code.should eq "89366"
Faker::Address.postcode.should eq "JA95 9QF"
Faker::Address.time_zone.should eq "Pacific/Honolulu"
Faker::Address.street_suffix.should eq "Loop"
Faker::Address.city_suffix.should eq "mouth"
Faker::Address.city_prefix.should eq "Lake"
Faker::Address.state.should eq "Montana"
Faker::Address.state_abbr.should eq "VA"
Faker::Address.country.should eq "Swaziland"
Faker::Address.country_code.should eq "MK"
Faker::Address.latitude.should eq "-23.850993082533705"
Faker::Address.longitude.should eq "-4.488135572134695"
end
end

View File

@ -3,8 +3,8 @@ require "./spec_helper"
describe Faker::Business do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Business.credit_card_number.should eq "1234-2121-1221-1211"
Faker::Business.credit_card_number.should eq "1228-1221-1221-1431"
Faker::Business.credit_card_expiry_date.should eq Time.new(2013, 9, 12)
Faker::Business.credit_card_type.should eq "diners_club"
Faker::Business.credit_card_type.should eq "mastercard"
end
end

View File

@ -55,12 +55,12 @@ describe Faker::Commerce do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Commerce.color.should eq "salmon"
Faker::Commerce.department.should eq "Home, Movies & Computers"
Faker::Commerce.department(5).should eq "Toys & Home"
Faker::Commerce.department(2, true).should eq "Electronics & Tools"
Faker::Commerce.product_name.should eq "Heavy Duty Copper Lamp"
Faker::Commerce.price.should eq 47.25
Faker::Commerce.material.should eq "Rubber"
Faker::Commerce.color.should eq "fuchsia"
Faker::Commerce.department.should eq "Garden & Tools"
Faker::Commerce.department(5).should eq "Kids, Health, Tools & Music"
Faker::Commerce.department(2, true).should eq "Garden & Industrial"
Faker::Commerce.product_name.should eq "Durable Aluminum Bag"
Faker::Commerce.price.should eq 62.86
Faker::Commerce.material.should eq "Leather"
end
end

View File

@ -8,8 +8,8 @@ describe Faker::Company do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Company.name.should eq "Larson-Altenwerth"
Faker::Company.suffix.should eq "Group"
Faker::Company.logo.should eq "https://pigment.github.io/fake-logos/logos/medium/color/12.png"
Faker::Company.name.should eq "Kemmer-Gleichner"
Faker::Company.suffix.should eq "Inc"
Faker::Company.logo.should eq "https://pigment.github.io/fake-logos/logos/medium/color/10.png"
end
end

View File

@ -32,10 +32,10 @@ describe Faker::Hacker do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Hacker.say_something_smart.should eq "You can't override the sensor without overriding the primary JBOD transmitter!"
Faker::Hacker.abbreviation.should eq "SCSI"
Faker::Hacker.adjective.should eq "primary"
Faker::Hacker.noun.should eq "pixel"
Faker::Hacker.say_something_smart.should eq "backing up the transmitter won't do anything, we need to bypass the optical RSS firewall!"
Faker::Hacker.abbreviation.should eq "USB"
Faker::Hacker.adjective.should eq "virtual"
Faker::Hacker.noun.should eq "port"
Faker::Hacker.verb.should eq "transmit"
Faker::Hacker.ingverb.should eq "calculating"
end

View File

@ -169,31 +169,31 @@ describe Faker::Internet do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Internet.email.should eq "internet_faker@kirlinblock.biz"
Faker::Internet.email("Nancy").should eq "nancy@cremin.io"
Faker::Internet.free_email.should eq "faker.internet@gmail.com"
Faker::Internet.free_email("Nancy").should eq "nancy@hotmail.com"
Faker::Internet.safe_email.should eq "faker_internet@example.net"
Faker::Internet.safe_email("Nancy").should eq "nancy@example.net"
Faker::Internet.user_name.should eq "faker.internet"
Faker::Internet.email.should eq "faker_internet@deckowboyer.biz"
Faker::Internet.email("Nancy").should eq "nancy@batz.org"
Faker::Internet.free_email.should eq "internet.faker@hotmail.com"
Faker::Internet.free_email("Nancy").should eq "nancy@yahoo.com"
Faker::Internet.safe_email.should eq "internet_faker@example.org"
Faker::Internet.safe_email("Nancy").should eq "nancy@example.com"
Faker::Internet.user_name.should eq "internet.faker"
Faker::Internet.user_name("Nancy").should eq "nancy"
Faker::Internet.user_name("Nancy Johnson", [".", "_", "-"] of ::String).should eq "johnson.nancy"
Faker::Internet.password.should eq "Tb34Ap05U"
Faker::Internet.password(8).should eq "BhI59sBo9"
Faker::Internet.password(10, 20).should eq "9r3b4iL8HeY"
Faker::Internet.password(10, 20, true).should eq "91JpPrF867Z"
Faker::Internet.password(10, 20, true, true).should eq "Pl5q3eOqZsK"
Faker::Internet.domain_name.should eq "ullrichklocko.biz"
Faker::Internet.domain_word.should eq "lockman"
Faker::Internet.domain_suffix.should eq "net"
Faker::Internet.ip_v4_address.should eq "6.70.63.244"
Faker::Internet.ip_v6_address.should eq "8a31:c21c:fb41:eea8:9df:aeab:9f78:5a49"
Faker::Internet.mac_address.should eq "00:4b:14:3d:24:55"
Faker::Internet.mac_address("55:44:33").should eq "55:44:33:36:0e:5d"
Faker::Internet.url.should eq "http://koelpin.biz/internet_faker"
Faker::Internet.url("example.com").should eq "http://example.com/faker_internet"
Faker::Internet.user_name("Nancy Johnson", [".", "_", "-"] of ::String).should eq "nancy-johnson"
Faker::Internet.password.should eq "NuSjR9XpA"
Faker::Internet.password(8).should eq "Tb7vMjXzD"
Faker::Internet.password(10, 20).should eq "Xc0qFgOxMo"
Faker::Internet.password(10, 20, true).should eq "J9GvT6LdLd7"
Faker::Internet.password(10, 20, true, true).should eq "#*^!#&@%^iG"
Faker::Internet.domain_name.should eq "hackett.net"
Faker::Internet.domain_word.should eq "murphy"
Faker::Internet.domain_suffix.should eq "co"
Faker::Internet.ip_v4_address.should eq "38.54.91.207"
Faker::Internet.ip_v6_address.should eq "f682:cc5a:cb38:94d3:7911:ff68:94df:f377"
Faker::Internet.mac_address.should eq "00:d0:57:d9:d8:d5"
Faker::Internet.mac_address("55:44:33").should eq "55:44:33:bc:fd:c8"
Faker::Internet.url.should eq "http://vonruedenlind.name/faker_internet"
Faker::Internet.url("example.com").should eq "http://example.com/internet_faker"
Faker::Internet.url("example.com", "/foobar.html").should eq "http://example.com/foobar.html"
Faker::Internet.slug.should eq "voluptatem.dicta"
Faker::Internet.slug.should eq "mollitia.nostrum"
Faker::Internet.slug("foo bar").should eq "foo.bar"
Faker::Internet.slug("foo bar", "-").should eq "foo-bar"
end

View File

@ -3,31 +3,27 @@ require "./spec_helper"
describe Faker::Lorem do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Lorem.word.should eq "voluptatem"
Faker::Lorem.words.should eq ["quos", "recusandae", "sed"]
Faker::Lorem.words(4).should eq ["iusto", "quia", "placeat", "quia"]
Faker::Lorem.words(4, true).should eq ["vis", "ambulo", "vesica", "vivo"]
Faker::Lorem.characters.should eq "xk7jz4c7a0w5ceh9opz68kq3xzdt5d2rtu29ky6jlb1ltxk3xvqkp87o2c7bs070wggzuz78an6t4cg8fejvhskgfe6ry104yc7kam8p91oaf6bqb61tp84q4958om8glep3wjrl9no32fj1eoklww8bzhvzmdkyp1tn51zxpzm8eynd7mbix1rimwrpufnut2a58d76mwrn4epjao7pedef2roosl2simxsvi4lejwzrdojegew2csobpw2lym"
Faker::Lorem.characters(10).should eq "vp5j8u3r1l"
Faker::Lorem.sentence.should eq "Itaque quod aliquam veritatis nemo dolorum sequi."
Faker::Lorem.sentence(3).should eq "Accusantium dolores suscipit praesentium."
Faker::Lorem.sentence(3, true).should eq "Spiculum triumphus necessitatibus appono angulus aut cariosus."
Faker::Lorem.sentence(3, false, 4).should eq "Atque sed perferendis minus."
Faker::Lorem.sentence(3, true, 4).should eq "Cohors traho tamdiu alveus itaque."
Faker::Lorem.sentences.should eq ["Sed ab quia.",
"Consequatur doloremque dolores ratione voluptas esse aut vero.",
"Qui dicta est odit nihil exercitationem nesciunt."]
Faker::Lorem.sentences(1).should eq ["Reiciendis doloremque vero sequi et quia."]
Faker::Lorem.sentences(1, true).should eq ["Concido quisquam cerno vulpes maxime mollitia."]
Faker::Lorem.paragraph.should eq "Maxime magnam vel velit id. Sed cupiditate blanditiis. Cupiditate sit aliquam vero."
Faker::Lorem.paragraph(2).should eq "Nemo laboriosam quod accusamus ab modi excepturi. Eveniet rerum quasi quia culpa. Vero quis aut. A assumenda tenetur."
Faker::Lorem.paragraph(2, true).should eq "Pecunia sopor ars vero subiungo quis urbanus. Demens minus delinquo."
Faker::Lorem.paragraph(2, false, 4).should eq "Mollitia delectus qui et ut quasi. Eligendi aut facilis praesentium ducimus qui. Itaque molestiae laudantium qui omnis veritatis soluta. Quia reiciendis dignissimos saepe architecto. Eum excepturi dolores iusto quisquam."
Faker::Lorem.paragraph(2, true, 4).should eq "Depraedor vitae spectaculum cupio acervus conatus adipisci. Pecus vulgivagus terra aliqua arbitro. Suscipio socius cupiditas arguo cetera colloco trans solitudo. Adimpleo stillicidium eaque ocer placeat adstringo ustulo balbus. Versus viduo videlicet tenus absconditus."
Faker::Lorem.paragraphs.should eq ["Rerum odit ducimus ipsum at sint. Consequatur sed non dolorem. Incidunt quae libero. Enim quam molestiae necessitatibus.",
"Inventore eos dolores asperiores corrupti cupiditate. Illum at molestiae cumque eaque aut. Blanditiis et laudantium neque. Consequatur labore officiis pariatur possimus facilis.",
"Esse fuga cum quisquam tenetur impedit rem repellat. Quia deleniti nulla. Excepturi perferendis dolor accusamus."]
Faker::Lorem.paragraphs(1).should eq ["Rerum unde voluptas sint autem. Fugit tenetur sequi totam esse. Explicabo omnis consequatur inventore autem. Et et praesentium neque quo natus."]
Faker::Lorem.paragraphs(1, true).should eq ["Conitor reiciendis minima viridis temporibus spiritus. Tabula crustulum error titulus et comptus. Coruscus turpis amplitudo combibo alias deludo triginta."]
Faker::Lorem.word.should eq "consequatur"
Faker::Lorem.words.should eq ["porro", "eos", "velit"]
Faker::Lorem.words(4).should eq ["illo", "omnis", "quam", "quia"]
Faker::Lorem.words(4, true).should eq ["abstergo", "volo", "congregatio", "cenaculum"]
Faker::Lorem.characters.should eq "rtu4oasce8rh8v9boy4o7dvw9da4ehtukyicl07az92gxkatlehuga41fqg8v06po1txnjcylbivmv5z9rcgg0hizegu4lck3rnja8kvpwiwp4lds3au07h9lk3k3y7a1c5ec2jtlo5zjtcm3blh6zgtk9rq8wpkqszhv0tstyydx8974aik0j2nkck9ve4kjmh0gn9als5wwxjwtot2yegk8jwe8plvbffu86w38abdq4cupnu4tig75lmu82g"
Faker::Lorem.characters(10).should eq "qunro8qzs5"
Faker::Lorem.sentence.should eq "Dicta laudantium aut aut et asperiores quidem accusamus impedit."
Faker::Lorem.sentence(3).should eq "Quam eum fugit."
Faker::Lorem.sentence(3, true).should eq "Caelum arma illum depopulo cupressus quaerat suus."
Faker::Lorem.sentence(3, false, 4).should eq "Est non necessitatibus."
Faker::Lorem.sentence(3, true, 4).should eq "Accedo venustas summisse cito sperno."
Faker::Lorem.sentences.should eq ["Voluptatem similique quia architecto quo.", "Culpa fugiat pariatur facilis ea accusantium voluptatem consequatur.", "Similique quis velit excepturi quia."]
Faker::Lorem.sentences(1).should eq ["Tempore repellat omnis."]
Faker::Lorem.sentences(1, true).should eq ["Aedificium adhuc patruus capio valens molestiae sit."]
Faker::Lorem.paragraph.should eq "Fugit repellendus suscipit dolores. Voluptatem adipisci nihil cupiditate quisquam ad. Est repellat consequuntur laboriosam reiciendis est sit. Vel molestiae ipsam."
Faker::Lorem.paragraph(2).should eq "Non consectetur itaque aut voluptas cumque est numquam. Non impedit quaerat iusto consequatur tempora nemo amet."
Faker::Lorem.paragraph(2, true).should eq "Pecus urbs curo vinitor volubilis. Coadunatio tunc quas compono. Vetus ascit adfectus civis minus tristis adulatio solio."
Faker::Lorem.paragraph(2, false, 4).should eq "Minima ducimus officia reprehenderit dolorem. Labore quia ut asperiores eos excepturi. Quibusdam tempore incidunt sunt quaerat provident."
Faker::Lorem.paragraph(2, true, 4).should eq "Tego vinco ultio celebrer eveniet cupio argentum speculum. Candidus arbor quibusdam angulus termes. Strenuus concido vulnero. Desino assentator deludo stabilis vallum autem demergo. Temeritas tristis nihil aperio acerbitas."
Faker::Lorem.paragraphs.should eq ["Voluptatem id dolor tempora. Praesentium harum dolores et explicabo unde ut. Sit deleniti vel ullam enim neque non itaque. Rerum qui quam quis et voluptate. Modi tenetur eius molestiae.", "Eaque pariatur quasi optio aliquam nihil quibusdam inventore. Voluptas eaque est nesciunt tenetur vel. Accusamus et et.", "Distinctio cum deserunt quia natus eos debitis neque. Qui voluptates quisquam. Facilis voluptatem et. Nihil nostrum occaecati at."]
Faker::Lorem.paragraphs(1).should eq ["Libero voluptatem neque et autem aspernatur earum animi. Ut iure sed quo quasi dolores aut. Voluptas possimus voluptatem nisi."]
Faker::Lorem.paragraphs(1, true).should eq ["Cibo cognatus temporibus demulceo cinis. Voluptatibus vobis ver cursus aperiam sulum apostolus. Id animadverto caste. Summisse derideo vallum. Suspendo et denuo collum accendo tamisium verecundia iste."]
end
end

View File

@ -3,11 +3,11 @@ require "./spec_helper"
describe Faker::Name do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Name.name.should eq "Bernie Altenwerth"
Faker::Name.first_name.should eq "Ron"
Faker::Name.last_name.should eq "Block"
Faker::Name.prefix.should eq "Mrs."
Faker::Name.suffix.should eq "Sr."
Faker::Name.title.should eq "Product Markets Specialist"
Faker::Name.name.should eq "Danyka Gleichner DDS"
Faker::Name.first_name.should eq "Molly"
Faker::Name.last_name.should eq "Fay"
Faker::Name.prefix.should eq "Dr."
Faker::Name.suffix.should eq "DDS"
Faker::Name.title.should eq "Direct Markets Associate"
end
end

View File

@ -67,13 +67,13 @@ describe Faker::Number do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Number.number(10).should eq "6961710422"
Faker::Number.decimal(2).should eq "82.34"
Faker::Number.decimal(2, 3).should eq "21.217"
Faker::Number.hexadecimal(3).should eq "046"
Faker::Number.between(1, 10).should eq 2
Faker::Number.positive.should eq 3995.8054520295627
Faker::Number.negative.should eq -748.5527873256278
Faker::Number.digit.should eq "2"
Faker::Number.number(10).should eq "9394314441"
Faker::Number.decimal(2).should eq "12.05"
Faker::Number.decimal(2, 3).should eq "98.256"
Faker::Number.hexadecimal(3).should eq "37c"
Faker::Number.between(1, 10).should eq 9
Faker::Number.positive.should eq 352.4124353316201
Faker::Number.negative.should eq -4363.992315679857
Faker::Number.digit.should eq "9"
end
end

View File

@ -3,6 +3,6 @@ require "./spec_helper"
describe Faker::PhoneNumber do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::PhoneNumber.phone_number.should eq "361-710-4228 x23421"
Faker::PhoneNumber.phone_number.should eq "894.314.4411 x20598"
end
end

View File

@ -19,8 +19,8 @@ describe Faker::Team do
it "should return deterministic results when seeded" do
Faker.seed 123456
Faker::Team.creature.should eq "buffalo"
Faker::Team.name.should eq "Washington sorcerors"
Faker::Team.state.should eq "Delaware"
Faker::Team.creature.should eq "vampires"
Faker::Team.name.should eq "New Jersey griffins"
Faker::Team.state.should eq "Arkansas"
end
end

View File

@ -23,16 +23,16 @@ module Faker
def self.regexify(re)
re = re.source if re.is_a?(Regex)
re.gsub(/^\/?\^?/, "").gsub(/\$?\/?$/, "") # Ditch the anchors
.gsub(/\{(\d+)\}/) { "{#{$1},#{$1}}" }.gsub(/\?/, "{0,1}") # All {2} become {2,2} and ? become {0,1}
.gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) { |match| $1 * (Range.new($2.to_i, $3.to_i)).to_a.sample(@@rng) } # [12]{1,2} becomes [12] or [12][12]
.gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) { |match| $1 * ($2.to_i..$3.to_i).to_a.sample(@@rng) } # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
.gsub(/(\\?.)\{(\d+),(\d+)\}/) { |match| $1 * ($2.to_i..$3.to_i).to_a.sample(@@rng) } # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
.gsub(/\((.*?)\)/) { |match| match.gsub(/[\(\)]/, "").split("|").sample(@@rng) } # (this|that) becomes "this" or "that"
.gsub(/\[([^\]]+)\]/) { |match| match.gsub(/(\w\-\w)/) { |range| ((0...range.size).map { |i| range[i].to_s }).join("").split("-").to_a.sample(@@rng) } } # All A-Z inside of [] become C (or X, or whatever)
.gsub(/\[([^\]]+)\]/) { |match| $1.split("").sample(@@rng) } # All [ABC] become B (or A or C)
.gsub("\\d") { |match| (0..9).to_a.sample(@@rng) }
.gsub("\\w") { |match| (("A".."Z").to_a + (0..9).to_a).sample(@@rng) }
re.gsub(/^\/?\^?/, "").gsub(/\$?\/?$/, "") # Ditch the anchors
.gsub(/\{(\d+)\}/) { "{#{$1},#{$1}}" }.gsub(/\?/, "{0,1}") # All {2} become {2,2} and ? become {0,1}
.gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) { |match| $1 * (Range.new($2.to_i, $3.to_i)).to_a.sample(@@rng) } # [12]{1,2} becomes [12] or [12][12]
.gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) { |match| $1 * ($2.to_i..$3.to_i).to_a.sample(@@rng) } # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
.gsub(/(\\?.)\{(\d+),(\d+)\}/) { |match| $1 * ($2.to_i..$3.to_i).to_a.sample(@@rng) } # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
.gsub(/\((.*?)\)/) { |match| match.gsub(/[\(\)]/, "").split("|").sample(@@rng) } # (this|that) becomes "this" or "that"
.gsub(/\[([^\]]+)\]/) { |match| match.gsub(/(\w\-\w)/) { |range| ((0...range.size).map { |i| range[i].to_s }).join("").split("-").to_a.sample(@@rng) } } # All A-Z inside of [] become C (or X, or whatever)
.gsub(/\[([^\]]+)\]/) { |match| $1.split("").sample(@@rng) } # All [ABC] become B (or A or C)
.gsub("\\d") { |match| (0..9).to_a.sample(@@rng) }
.gsub("\\w") { |match| (("A".."Z").to_a + (0..9).to_a).sample(@@rng) }
end
def self.fetch(data)

View File

@ -6,7 +6,7 @@ module Faker
def self.credit_card_expiry_date
credit_card_expiry_date = Faker.fetch(Data["business"]["credit_card_expiry_dates"]).as String
Time.parse(credit_card_expiry_date, "%Y-%m-%d")
Time.parse_local(credit_card_expiry_date, "%Y-%m-%d")
end
def self.credit_card_type