Skip to content

Commit

Permalink
Merge pull request #114 from vladimir-ionita/feature/gender_generator
Browse files Browse the repository at this point in the history
Feature/gender generator
  • Loading branch information
vadymmarkov authored May 10, 2019
2 parents 47a87f9 + 8ce71aa commit de0ce7f
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Fakery.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@
D59B6D391D99C82E007CB072 /* NumberSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D59B6CFC1D99C5FD007CB072 /* NumberSpec.swift */; };
D59B6D3A1D99C82E007CB072 /* PhoneNumberSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D59B6CFD1D99C5FD007CB072 /* PhoneNumberSpec.swift */; };
D59B6D3B1D99C82E007CB072 /* TeamSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D59B6CFE1D99C5FD007CB072 /* TeamSpec.swift */; };
E1128FFA2283207B008F7FD1 /* GenderSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1128FF822831FAC008F7FD1 /* GenderSpec.swift */; };
E1128FFB22832080008F7FD1 /* GenderSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1128FF822831FAC008F7FD1 /* GenderSpec.swift */; };
E1128FFD22832235008F7FD1 /* Gender.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1128FFC22832235008F7FD1 /* Gender.swift */; };
E1128FFE22832248008F7FD1 /* Gender.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1128FFC22832235008F7FD1 /* Gender.swift */; };
E1128FFF22832248008F7FD1 /* Gender.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1128FFC22832235008F7FD1 /* Gender.swift */; };
F178E88722831FC400A166DC /* VehicleSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = F178E88522831FA600A166DC /* VehicleSpec.swift */; };
F178E88822831FC400A166DC /* VehicleSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = F178E88522831FA600A166DC /* VehicleSpec.swift */; };
F178E88A2283212B00A166DC /* Vehicle.swift in Sources */ = {isa = PBXBuildFile; fileRef = F178E8892283212B00A166DC /* Vehicle.swift */; };
Expand Down Expand Up @@ -289,6 +294,8 @@
D59B6D131D99C6C7007CB072 /* Info-Tests-Mac.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Tests-Mac.plist"; sourceTree = "<group>"; };
D59B6D141D99C6C7007CB072 /* Info-Tests-tvOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Tests-tvOS.plist"; sourceTree = "<group>"; };
D59B6D151D99C6C7007CB072 /* Info-tvOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-tvOS.plist"; sourceTree = "<group>"; };
E1128FF822831FAC008F7FD1 /* GenderSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenderSpec.swift; sourceTree = "<group>"; };
E1128FFC22832235008F7FD1 /* Gender.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Gender.swift; sourceTree = "<group>"; };
F178E88522831FA600A166DC /* VehicleSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleSpec.swift; sourceTree = "<group>"; };
F178E8892283212B00A166DC /* Vehicle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Vehicle.swift; sourceTree = "<group>"; };
F7A0198F22831FCB00B92D39 /* HamSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HamSpec.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -435,6 +442,7 @@
BCFFA16C1BF9F912005A3BC1 /* Business.swift */,
BCFFA16D1BF9F912005A3BC1 /* Commerce.swift */,
BCFFA16E1BF9F912005A3BC1 /* Company.swift */,
E1128FFC22832235008F7FD1 /* Gender.swift */,
BCFFA16F1BF9F912005A3BC1 /* Generator.swift */,
BCFFA1701BF9F912005A3BC1 /* Internet.swift */,
BCFFA1711BF9F912005A3BC1 /* Lorem.swift */,
Expand Down Expand Up @@ -499,6 +507,7 @@
D59B6CF51D99C5FD007CB072 /* BusinessSpec.swift */,
D59B6CF61D99C5FD007CB072 /* CommerceSpec.swift */,
D59B6CF71D99C5FD007CB072 /* CompanySpec.swift */,
E1128FF822831FAC008F7FD1 /* GenderSpec.swift */,
D59B6CF81D99C5FD007CB072 /* GeneratorSpec.swift */,
D59B6CF91D99C5FD007CB072 /* InternetSpec.swift */,
D59B6CFA1D99C5FD007CB072 /* LoremSpec.swift */,
Expand Down Expand Up @@ -919,6 +928,7 @@
BC4477961BFA451F00E8FB15 /* Company.swift in Sources */,
BC4477A01BFA454400E8FB15 /* Config.swift in Sources */,
1057479E1F6FBF7100154ECB /* Bank.swift in Sources */,
E1128FFE22832248008F7FD1 /* Gender.swift in Sources */,
AC8156A92153C27E00D779EF /* Date.swift in Sources */,
BC44779F1BFA453F00E8FB15 /* Provider.swift in Sources */,
BC44779D1BFA453800E8FB15 /* ArrayExtension.swift in Sources */,
Expand All @@ -933,6 +943,7 @@
D59B6D351D99C82E007CB072 /* GeneratorSpec.swift in Sources */,
D59B6D2D1D99C82E007CB072 /* FakerSpec.swift in Sources */,
D59B6D301D99C82E007CB072 /* AddressSpec.swift in Sources */,
E1128FFB22832080008F7FD1 /* GenderSpec.swift in Sources */,
AC88DC0F215330A4007198E6 /* DateSpec.swift in Sources */,
D59B6D371D99C82E007CB072 /* LoremSpec.swift in Sources */,
D59B6D391D99C82E007CB072 /* NumberSpec.swift in Sources */,
Expand Down Expand Up @@ -976,6 +987,7 @@
BCFFA1A01BF9F912005A3BC1 /* Team.swift in Sources */,
BCFFA1941BF9F912005A3BC1 /* ArrayExtension.swift in Sources */,
1057479D1F6FBF6C00154ECB /* Bank.swift in Sources */,
E1128FFD22832235008F7FD1 /* Gender.swift in Sources */,
AC88DC0B21531E2E007198E6 /* Date.swift in Sources */,
BCFFA19E1BF9F912005A3BC1 /* Name.swift in Sources */,
BCFFA1991BF9F912005A3BC1 /* Commerce.swift in Sources */,
Expand All @@ -990,6 +1002,7 @@
D59B6D251D99C82D007CB072 /* GeneratorSpec.swift in Sources */,
D59B6D1D1D99C82D007CB072 /* FakerSpec.swift in Sources */,
D59B6D201D99C82D007CB072 /* AddressSpec.swift in Sources */,
E1128FFA2283207B008F7FD1 /* GenderSpec.swift in Sources */,
AC88DC0E215330A4007198E6 /* DateSpec.swift in Sources */,
D59B6D271D99C82D007CB072 /* LoremSpec.swift in Sources */,
D59B6D291D99C82D007CB072 /* NumberSpec.swift in Sources */,
Expand Down Expand Up @@ -1033,6 +1046,7 @@
D59B6CA31D99C464007CB072 /* ArrayExtension.swift in Sources */,
D59B6CAD1D99C46C007CB072 /* Name.swift in Sources */,
1057479F1F6FBF7100154ECB /* Bank.swift in Sources */,
E1128FFF22832248008F7FD1 /* Gender.swift in Sources */,
AC8156AA2153C27F00D779EF /* Date.swift in Sources */,
D59B6CA81D99C46C007CB072 /* Commerce.swift in Sources */,
D59B6CAF1D99C46C007CB072 /* PhoneNumber.swift in Sources */,
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ It's useful in all the cases when you need to use some dummy data for testing, p
* [Business](#business)
* [Commerce](#commerce)
* [Company](#company)
* [Gender](#gender)
* [Internet](#internet)
* [Lorem](#lorem)
* [Name](#name)
Expand Down Expand Up @@ -122,6 +123,14 @@ faker.company.bs() //=> "implement innovative methodologies"
faker.company.logo() // "http://pigment.github.io/fake-logos/logos/medium/color/1.png"
```

### Gender

```swift

faker.gender.type() //=> "Agender"
faker.gender.binaryType() //=> "Male"
```

### Internet

```swift
Expand Down
6 changes: 5 additions & 1 deletion Resources/Locales/en-TEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@
},
"ham": {
"name": ["Smithfield Ham"]
},
"gender": {
"type": ["Non-binary"],
"binary_type": ["Male"]
}
}
}
}
}
16 changes: 16 additions & 0 deletions Resources/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10919,6 +10919,22 @@
"Canned Ham",
"Pressed Ham"
]
},
"gender": {
"type": [
"Male",
"Female",
"Non-binary",
"Agender",
"Genderfluid",
"Genderqueer",
"Bigender",
"Polygender"
],
"binary_type": [
"Male",
"Female"
]
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Resources/Locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,12 @@
"+33 7########",
"+33 8########"
]
},
"gender": {
"binary_type": [
"Masculin",
"Féminin"
]
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Resources/Locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@
"name": [
"#{last_name} #{first_name}"
]
},
"gender": {
"binary_type": [
"女性",
"男性"
]
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Fakery/Faker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public final class Faker {
public let business: Business
public let company: Company
public let commerce: Commerce
public let gender: Gender
public let internet: Internet
public let lorem: Lorem
public let name: Name
Expand All @@ -36,6 +37,7 @@ public final class Faker {
business = Business(parser: parser)
company = Company(parser: parser)
commerce = Commerce(parser: parser)
gender = Gender(parser: parser)
internet = Internet(parser: parser)
lorem = Lorem(parser: parser)
name = Name(parser: parser)
Expand Down
11 changes: 11 additions & 0 deletions Sources/Fakery/Generators/Gender.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

public final class Gender: Generator {
public func type() -> String {
return generate("gender.type")
}

public func binaryType() -> String {
return generate("gender.binary_type")
}
}
7 changes: 7 additions & 0 deletions Tests/Fakery/FakerSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final class FakerSpec: QuickSpec {
expect(faker.app.parser).to(beIdenticalTo(faker.parser))
expect(faker.business.parser).to(beIdenticalTo(faker.parser))
expect(faker.commerce.parser).to(beIdenticalTo(faker.parser))
expect(faker.gender.parser).to(beIdenticalTo(faker.parser))
expect(faker.internet.parser).to(beIdenticalTo(faker.parser))
expect(faker.lorem.parser).to(beIdenticalTo(faker.parser))
expect(faker.name.parser).to(beIdenticalTo(faker.parser))
Expand Down Expand Up @@ -55,6 +56,12 @@ final class FakerSpec: QuickSpec {
expect(faker.commerce).to(beAKindOf(Commerce.self))
}
}

describe("#gender") {
it("should be accessible") {
expect(faker.gender).to(beAKindOf(Gender.self))
}
}

describe("#internet") {
it("should be accessible") {
Expand Down
30 changes: 30 additions & 0 deletions Tests/Fakery/Generators/GenderSpec.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Quick
import Nimble
@testable import Fakery

final class GenderSpec: QuickSpec {
override func spec() {
describe("Gender") {
var gender: Gender!

beforeEach {
let parser = Parser(locale: "en-TEST")
gender = Gender(parser: parser)
}

describe("#type") {
it("returns the correct text") {
let type = gender.type()
expect(type).to(equal("Non-binary"))
}
}

describe("#binary_type") {
it("returns the correct text") {
let binaryType = gender.binaryType()
expect(binaryType).to(equal("Male"))
}
}
}
}
}

0 comments on commit de0ce7f

Please sign in to comment.