Skip to content

Commit

Permalink
Merge pull request vadymmarkov#116 from 51d4/Feature/Cat
Browse files Browse the repository at this point in the history
Add Cat generator
  • Loading branch information
vadymmarkov authored May 10, 2019
2 parents de0ce7f + 693be64 commit e3ff228
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Fakery.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
105747A11F6FFB9F00154ECB /* nl.json in Resources */ = {isa = PBXBuildFile; fileRef = 105747A01F6FFB9F00154ECB /* nl.json */; };
105747A21F6FFB9F00154ECB /* nl.json in Resources */ = {isa = PBXBuildFile; fileRef = 105747A01F6FFB9F00154ECB /* nl.json */; };
105747A31F6FFB9F00154ECB /* nl.json in Resources */ = {isa = PBXBuildFile; fileRef = 105747A01F6FFB9F00154ECB /* nl.json */; };
20580DDE2283205E00D46446 /* CatSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20580DDD2283205E00D46446 /* CatSpec.swift */; };
20580DDF2283205E00D46446 /* CatSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20580DDD2283205E00D46446 /* CatSpec.swift */; };
20580DE12283222C00D46446 /* Cat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20580DE02283222C00D46446 /* Cat.swift */; };
20580DE22283222C00D46446 /* Cat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20580DE02283222C00D46446 /* Cat.swift */; };
20580DE32283222C00D46446 /* Cat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20580DE02283222C00D46446 /* Cat.swift */; };
2A17AB0A1E4E45A600011BC6 /* tr-TR.json in Resources */ = {isa = PBXBuildFile; fileRef = 2A17AB091E4E45A600011BC6 /* tr-TR.json */; };
AC8156A92153C27E00D779EF /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC88DC0A21531E2E007198E6 /* Date.swift */; };
AC8156AA2153C27F00D779EF /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC88DC0A21531E2E007198E6 /* Date.swift */; };
Expand Down Expand Up @@ -224,6 +229,8 @@
105747991F6FBAA500154ECB /* BankSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BankSpec.swift; sourceTree = "<group>"; };
1057479C1F6FBF6C00154ECB /* Bank.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bank.swift; sourceTree = "<group>"; };
105747A01F6FFB9F00154ECB /* nl.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = nl.json; sourceTree = "<group>"; };
20580DDD2283205E00D46446 /* CatSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CatSpec.swift; sourceTree = "<group>"; };
20580DE02283222C00D46446 /* Cat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cat.swift; sourceTree = "<group>"; };
2A17AB091E4E45A600011BC6 /* tr-TR.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "tr-TR.json"; sourceTree = "<group>"; };
AC88DC0A21531E2E007198E6 /* Date.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Date.swift; sourceTree = "<group>"; };
AC88DC0C215330A3007198E6 /* DateSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateSpec.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -440,6 +447,7 @@
BCFFA16A1BF9F912005A3BC1 /* Address.swift */,
BCFFA16B1BF9F912005A3BC1 /* App.swift */,
BCFFA16C1BF9F912005A3BC1 /* Business.swift */,
20580DE02283222C00D46446 /* Cat.swift */,
BCFFA16D1BF9F912005A3BC1 /* Commerce.swift */,
BCFFA16E1BF9F912005A3BC1 /* Company.swift */,
E1128FFC22832235008F7FD1 /* Gender.swift */,
Expand Down Expand Up @@ -505,6 +513,7 @@
D59B6CF31D99C5FD007CB072 /* AddressSpec.swift */,
D59B6CF41D99C5FD007CB072 /* AppSpec.swift */,
D59B6CF51D99C5FD007CB072 /* BusinessSpec.swift */,
20580DDD2283205E00D46446 /* CatSpec.swift */,
D59B6CF61D99C5FD007CB072 /* CommerceSpec.swift */,
D59B6CF71D99C5FD007CB072 /* CompanySpec.swift */,
E1128FF822831FAC008F7FD1 /* GenderSpec.swift */,
Expand Down Expand Up @@ -924,6 +933,7 @@
BC4477921BFA451400E8FB15 /* Address.swift in Sources */,
BC4477971BFA452100E8FB15 /* Generator.swift in Sources */,
BC4477911BFA450D00E8FB15 /* Faker.swift in Sources */,
20580DE22283222C00D46446 /* Cat.swift in Sources */,
BC4477991BFA452700E8FB15 /* Lorem.swift in Sources */,
BC4477961BFA451F00E8FB15 /* Company.swift in Sources */,
BC4477A01BFA454400E8FB15 /* Config.swift in Sources */,
Expand Down Expand Up @@ -955,6 +965,7 @@
D59B6D331D99C82E007CB072 /* CommerceSpec.swift in Sources */,
D59B6D2E1D99C82E007CB072 /* ParserSpec.swift in Sources */,
D59B6D321D99C82E007CB072 /* BusinessSpec.swift in Sources */,
20580DDF2283205E00D46446 /* CatSpec.swift in Sources */,
D59B6D3B1D99C82E007CB072 /* TeamSpec.swift in Sources */,
F7A019912283206600B92D39 /* HamSpec.swift in Sources */,
D59B6D3A1D99C82E007CB072 /* PhoneNumberSpec.swift in Sources */,
Expand Down Expand Up @@ -983,6 +994,7 @@
BCFFA19F1BF9F912005A3BC1 /* PhoneNumber.swift in Sources */,
BCFFA19B1BF9F912005A3BC1 /* Generator.swift in Sources */,
BCFFA1981BF9F912005A3BC1 /* Business.swift in Sources */,
20580DE12283222C00D46446 /* Cat.swift in Sources */,
BCFFA1971BF9F912005A3BC1 /* App.swift in Sources */,
BCFFA1A01BF9F912005A3BC1 /* Team.swift in Sources */,
BCFFA1941BF9F912005A3BC1 /* ArrayExtension.swift in Sources */,
Expand Down Expand Up @@ -1014,6 +1026,7 @@
D59B6D231D99C82D007CB072 /* CommerceSpec.swift in Sources */,
D59B6D1E1D99C82D007CB072 /* ParserSpec.swift in Sources */,
D59B6D221D99C82D007CB072 /* BusinessSpec.swift in Sources */,
20580DDE2283205E00D46446 /* CatSpec.swift in Sources */,
D59B6D2B1D99C82D007CB072 /* TeamSpec.swift in Sources */,
F7A019902283206600B92D39 /* HamSpec.swift in Sources */,
D59B6D2A1D99C82D007CB072 /* PhoneNumberSpec.swift in Sources */,
Expand Down Expand Up @@ -1042,6 +1055,7 @@
D59B6CAB1D99C46C007CB072 /* Internet.swift in Sources */,
D59B6CAA1D99C46C007CB072 /* Generator.swift in Sources */,
D59B6CA71D99C46C007CB072 /* Business.swift in Sources */,
20580DE32283222C00D46446 /* Cat.swift in Sources */,
D59B6CA61D99C46C007CB072 /* App.swift in Sources */,
D59B6CA31D99C464007CB072 /* ArrayExtension.swift in Sources */,
D59B6CAD1D99C46C007CB072 /* Name.swift in Sources */,
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ It's useful in all the cases when you need to use some dummy data for testing, p
* [Address](#address)
* [App](#app)
* [Business](#business)
* [Cat](#cat)
* [Commerce](#commerce)
* [Company](#company)
* [Gender](#gender)
Expand Down Expand Up @@ -102,6 +103,15 @@ faker.business.creditCardType() //=> "visa"
faker.business.creditCardExpiryDate() //=> "2020-10-12"
```

### Cat

```swift

faker.cat.name() //=> "Shadow"
faker.cat.breed() //=> "British Semipi-longhair"
faker.cat.registry() //=> "American Cat Fanciers Association"
```

### Commerce

```swift
Expand Down
9 changes: 7 additions & 2 deletions Resources/Locales/en-TEST.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"en-TEST": {
{
"en-TEST": {
"faker": {
"separator": " & ",
"address": {
Expand All @@ -23,6 +23,11 @@
"street_address": ["#{building_number} #{street_name}"],
"default_country": ["United States of America"]
},
"cat": {
"name": ["Shadow"],
"breed": ["British Semipi-longhair"],
"registry": ["American Cat Fanciers Association"]
},
"credit_card": {
"visa": ["/4###########L/"],
"mastercard": ["/5[1-5]##-####-####-###L/"],
Expand Down
145 changes: 144 additions & 1 deletion Resources/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4143,6 +4143,149 @@
"United States of America"
]
},
"cat": {
"name": [
"Alfie",
"Angel",
"Bella",
"Charlie",
"Chloe",
"Coco",
"Daisy",
"Felix",
"Jasper",
"Lily",
"Lucky",
"Lucy",
"Max",
"Millie",
"Milo",
"Missy",
"Misty",
"Molly",
"Oliver",
"Oscar",
"Poppy",
"Sam",
"Shadow",
"Simba",
"Smokey",
"Smudge",
"Sooty",
"Tiger"
],
"breed": [
"Abyssinian",
"Aegean",
"American Bobtail",
"American Curl",
"American Shorthair",
"American Wirehair",
"Arabian Mau",
"Asian",
"Asian Semi-longhair",
"Australian Mist",
"Balinese",
"Bambino",
"Bengal",
"Birman",
"Bombay",
"Brazilian Shorthair",
"British Longhair",
"British Semipi-longhair",
"British Shorthair",
"Burmese",
"Burmilla",
"California Spangled",
"Chantilly-Tiffany",
"Chartreux",
"Chausie",
"Cheetoh",
"Colorpoint Shorthair",
"Cornish Rex",
"Cymric, or Manx Longhair",
"Cyprus",
"Devon Rex",
"Donskoy, or Don Sphynx",
"Dragon Li",
"Dwarf cat, or Dwelf",
"Egyptian Mau",
"European Shorthair",
"Exotic Shorthair",
"Foldex Cat",
"German Rex",
"Havana Brown",
"Highlander",
"Himalayan, or Colorpoint Persian",
"Japanese Bobtail",
"Javanese",
"Khao Manee",
"Korat",
"Korean Bobtail",
"Korn Ja",
"Kurilian Bobtail",
"Kurilian Bobtail, or Kuril Islands Bobtail",
"LaPerm",
"Lykoi",
"Maine Coon",
"Manx",
"Mekong Bobtail",
"Minskin",
"Munchkin",
"Napoleon",
"Nebelung",
"Norwegian Forest Cat",
"Ocicat",
"Ojos Azules",
"Oregon Rex",
"Oriental Bicolor",
"Oriental Longhair",
"Oriental Shorthair",
"PerFold Cat (Experimental Breed - WCF)",
"Persian (Modern Persian Cat)",
"Persian (Traditional Persian Cat)",
"Peterbald",
"Pixie-bob",
"Raas",
"Ragamuffin",
"Ragdoll",
"Russian Blue",
"Russian White, Black and Tabby",
"Sam Sawet",
"Savannah",
"Scottish Fold",
"Selkirk Rex",
"Serengeti",
"Serrade petit",
"Siamese",
"Siberian",
"Singapura",
"Snowshoe",
"Sokoke",
"Somali",
"Sphynx",
"Suphalak",
"Thai",
"Tonkinese",
"Toyger",
"Turkish Angora",
"Turkish Van",
"Ukrainian Levkoy"
],
"registry": [
"American Cat Fanciers Association",
"Associazione Nazionale Felina Italiana",
"Canadian Cat Association",
"Cat Aficionado Association",
"Cat Fanciers' Association",
"Emirates Feline Federation",
"Fédération Internationale Féline",
"Felis Britannica",
"Governing Council of the Cat",
"Fancy Southern Africa Cat Council",
"The International Cat Association"
]
},
"credit_card": {
"visa": [
"/4###########L/",
Expand Down Expand Up @@ -10938,4 +11081,4 @@
}
}
}
}
}
2 changes: 2 additions & 0 deletions Sources/Fakery/Faker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public final class Faker {
public let address: Address
public let app: App
public let business: Business
public let cat: Cat
public let company: Company
public let commerce: Commerce
public let gender: Gender
Expand All @@ -35,6 +36,7 @@ public final class Faker {
address = Address(parser: parser)
app = App(parser: parser)
business = Business(parser: parser)
cat = Cat(parser: parser)
company = Company(parser: parser)
commerce = Commerce(parser: parser)
gender = Gender(parser: parser)
Expand Down
15 changes: 15 additions & 0 deletions Sources/Fakery/Generators/Cat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

public final class Cat: Generator {
public func name() -> String {
return generate("cat.name")
}

public func breed() -> String {
return generate("cat.breed")
}

public func registry() -> String {
return generate("cat.registry")
}
}
37 changes: 37 additions & 0 deletions Tests/Fakery/Generators/CatSpec.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Quick
import Nimble
@testable import Fakery

final class CatSpec: QuickSpec {
override func spec() {
describe("Cat") {
var cat: Cat!

beforeEach {
let parser = Parser(locale: "en-TEST")
cat = Cat(parser: parser)
}

describe("#name") {
it("returns the correct text") {
let name = cat.name()
expect(name).to(equal("Shadow"))
}
}

describe("#breed") {
it("returns the correct text") {
let breed = cat.breed()
expect(breed).to(equal("British Semipi-longhair"))
}
}

describe("#registry") {
it("returns the correct text") {
let registry = cat.registry()
expect(registry).to(equal("American Cat Fanciers Association"))
}
}
}
}
}

0 comments on commit e3ff228

Please sign in to comment.