├── .github └── workflows │ ├── ci.yml │ ├── spm.yml │ └── swiftlint.yml ├── .gitignore ├── .swift-version ├── .swiftlint.yml ├── CONTRIBUTING.md ├── Fakery.podspec ├── Fakery.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── swiftpm │ │ └── Package.resolved └── xcshareddata │ └── xcschemes │ ├── Fakery-iOS.xcscheme │ ├── Fakery-macOS.xcscheme │ └── Fakery-tvOS.xcscheme ├── Images └── logo.png ├── LICENSE.md ├── Package.resolved ├── Package.swift ├── Project ├── Info-Mac.plist ├── Info-Tests-Mac.plist ├── Info-Tests-iOS.plist ├── Info-Tests-tvOS.plist ├── Info-iOS.plist └── Info-tvOS.plist ├── README.md ├── README.md.orig ├── Resources ├── Sources └── Fakery │ ├── Config.swift │ ├── Data │ ├── Parser.swift │ └── Provider.swift │ ├── Extensions │ ├── ArrayExtension.swift │ └── StringExtensions.swift │ ├── Faker.swift │ ├── Generators │ ├── Address.swift │ ├── App.swift │ ├── Bank.swift │ ├── Business.swift │ ├── Car.swift │ ├── Cat.swift │ ├── Commerce.swift │ ├── Company.swift │ ├── Date.swift │ ├── Gender.swift │ ├── Generator.swift │ ├── Ham.swift │ ├── Hobbit.swift │ ├── House.swift │ ├── Internet.swift │ ├── Lorem.swift │ ├── Name.swift │ ├── Number.swift │ ├── PhoneNumber.swift │ ├── ProgrammingLanguage.swift │ ├── Team.swift │ ├── Vehicle.swift │ └── Zelda.swift │ └── Resources │ └── Locales │ ├── de-AT.json │ ├── de-CH.json │ ├── de.json │ ├── en-AU.json │ ├── en-CA.json │ ├── en-GB.json │ ├── en-IND.json │ ├── en-TEST.json │ ├── en-US.json │ ├── en.json │ ├── es.json │ ├── fa.json │ ├── fr.json │ ├── it.json │ ├── ja.json │ ├── ko.json │ ├── nb-NO.json │ ├── nl.json │ ├── pl.json │ ├── pt-BR.json │ ├── ru.json │ ├── sk.json │ ├── sv.json │ ├── tr-TR.json │ ├── uk.json │ ├── zh-CN.json │ └── zh-TW.json └── Tests ├── Fakery ├── ConfigSpec.swift ├── Data │ ├── ParserSpec.swift │ └── ProviderSpec.swift ├── FakerSpec.swift └── Generators │ ├── AddressSpec.swift │ ├── AppSpec.swift │ ├── BankSpec.swift │ ├── BusinessSpec.swift │ ├── CarSpec.swift │ ├── CatSpec.swift │ ├── CommerceSpec.swift │ ├── CompanySpec.swift │ ├── DateSpec.swift │ ├── GenderSpec.swift │ ├── GeneratorSpec.swift │ ├── HamSpec.swift │ ├── HobbitSpec.swift │ ├── HouseSpec.swift │ ├── InternetSpec.swift │ ├── LoremSpec.swift │ ├── NameSpec.swift │ ├── NumberSpec.swift │ ├── PhoneNumberSpec.swift │ ├── ProgrammingLanguageSpec.swift │ ├── TeamSpec.swift │ ├── VehicleSpec.swift │ └── ZeldaSpec.swift └── LinuxMain.swift /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Xcode 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: macos-latest 13 | 14 | strategy: 15 | matrix: 16 | run-config: 17 | - { scheme: 'Fakery-iOS', destination: 'platform=iOS Simulator,name=iPhone 13 Pro,OS=15.2' } 18 | - { scheme: 'Fakery-macOS', destination: 'platform=macOS' } 19 | 20 | steps: 21 | - name: Checkout Project 22 | uses: actions/checkout@v1 23 | 24 | - name: Show the currently detailed version of Xcode for CLI 25 | run: xcode-select -p 26 | 27 | - name: Show Build Settings 28 | run: xcodebuild -project Fakery.xcodeproj -scheme '${{ matrix.run-config['scheme'] }}' -showBuildSettings 29 | 30 | - name: Show Build SDK 31 | run: xcodebuild -project Fakery.xcodeproj -scheme '${{ matrix.run-config['scheme'] }}' -showsdks 32 | 33 | - name: Show Available Destinations 34 | run: xcodebuild -project Fakery.xcodeproj -scheme '${{ matrix.run-config['scheme'] }}' -showdestinations 35 | 36 | - name: build and test 37 | run: xcodebuild clean test -scheme '${{ matrix.run-config['scheme'] }}' -destination '${{ matrix.run-config['destination'] }}' -showBuildTimingSummary 38 | -------------------------------------------------------------------------------- /.github/workflows/spm.yml: -------------------------------------------------------------------------------- 1 | name: SPM 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: macos-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Build 17 | run: swift build -v 18 | - name: Run tests 19 | run: swift test -v 20 | -------------------------------------------------------------------------------- /.github/workflows/swiftlint.yml: -------------------------------------------------------------------------------- 1 | name: SwiftLint 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - '.github/workflows/swiftlint.yml' 7 | - '.swiftlint.yml' 8 | - '**/*.swift' 9 | 10 | jobs: 11 | lint: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: norio-nomura/action-swiftlint@3.2.1 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Carthage 2 | Carthage/ 3 | 4 | # OS X 5 | .DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | Icon 9 | ._* 10 | .Spotlight-V100 11 | .Trashes 12 | 13 | # Xcode 14 | # 15 | build/ 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | xcuserdata 25 | *.xccheckout 26 | *.moved-aside 27 | DerivedData 28 | *.hmap 29 | *.ipa 30 | *.xcuserstate 31 | 32 | # CocoaPods 33 | Pods 34 | 35 | Packages 36 | .build 37 | .swiftpm 38 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.3.1 2 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | included: 2 | - Sources 3 | - Tests 4 | excluded: 5 | - Carthage 6 | - Pods 7 | - Packages 8 | opt_in_rules: 9 | - empty_count 10 | disabled_rules: 11 | - valid_docs 12 | - type_name 13 | force_cast: warning 14 | force_try: 15 | severity: warning 16 | line_length: 120 17 | function_body_length: 18 | - 150 19 | type_body_length: 20 | warning: 300 21 | error: 400 22 | file_length: 23 | warning: 500 24 | error: 1200 25 | type_name: 26 | min_length: 3 27 | max_length: 28 | warning: 40 29 | error: 50 30 | variable_name: 31 | min_length: 2 32 | reporter: "xcode" 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | GitHub Issues is for reporting bugs, discussing features and general feedback in **Fakery**. Be sure to check our [documentation](http://cocoadocs.org/docsets/Fakery), [FAQ](https://github.com/vadymmarkov/Fakery/wiki/FAQ) and [past issues](https://github.com/vadymmarkov/Fakery/issues?state=closed) before opening any new issues. 2 | 3 | If you are posting about a crash in your application, a stack trace is helpful, but additional context, in the form of code and explanation, is necessary to be of any use. 4 | -------------------------------------------------------------------------------- /Fakery.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Fakery" 3 | s.version = "5.1.0" 4 | s.summary = "Swift fake data generator" 5 | s.homepage = "https://github.com/vadymmarkov/Fakery" 6 | s.license = { 7 | :type => 'MIT', 8 | :file => 'LICENSE.md' 9 | } 10 | s.author = { 11 | "Vadym Markov" => "markov.vadym@gmail.com" 12 | } 13 | 14 | s.source = { 15 | :git => "https://github.com/vadymmarkov/Fakery.git", 16 | :tag => s.version.to_s 17 | } 18 | 19 | s.social_media_url = 'https://twitter.com/vadymmarkov' 20 | 21 | s.ios.deployment_target = "8.0" 22 | s.osx.deployment_target = "10.9" 23 | s.tvos.deployment_target = "9.0" 24 | s.requires_arc = true 25 | 26 | s.resources = 'Sources/Fakery/Resources/Locales/*.{json}' 27 | 28 | s.source_files = 'Sources/**/*.{swift}' 29 | s.frameworks = 'Foundation' 30 | end 31 | -------------------------------------------------------------------------------- /Fakery.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Fakery.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Fakery.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "CwlCatchException", 6 | "repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "f809deb30dc5c9d9b78c872e553261a61177721a", 10 | "version": "2.0.0" 11 | } 12 | }, 13 | { 14 | "package": "CwlPreconditionTesting", 15 | "repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git", 16 | "state": { 17 | "branch": null, 18 | "revision": "02b7a39a99c4da27abe03cab2053a9034379639f", 19 | "version": "2.0.0" 20 | } 21 | }, 22 | { 23 | "package": "Nimble", 24 | "repositoryURL": "https://github.com/Quick/Nimble.git", 25 | "state": { 26 | "branch": null, 27 | "revision": "e491a6731307bb23783bf664d003be9b2fa59ab5", 28 | "version": "9.0.0" 29 | } 30 | }, 31 | { 32 | "package": "Quick", 33 | "repositoryURL": "https://github.com/Quick/Quick.git", 34 | "state": { 35 | "branch": null, 36 | "revision": "8cce6acd38f965f5baa3167b939f86500314022b", 37 | "version": "3.1.2" 38 | } 39 | } 40 | ] 41 | }, 42 | "version": 1 43 | } 44 | -------------------------------------------------------------------------------- /Fakery.xcodeproj/xcshareddata/xcschemes/Fakery-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 48 | 49 | 50 | 51 | 52 | 62 | 63 | 69 | 70 | 71 | 72 | 78 | 79 | 85 | 86 | 87 | 88 | 90 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /Fakery.xcodeproj/xcshareddata/xcschemes/Fakery-macOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 48 | 49 | 50 | 51 | 52 | 62 | 63 | 69 | 70 | 71 | 72 | 78 | 79 | 85 | 86 | 87 | 88 | 90 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /Fakery.xcodeproj/xcshareddata/xcschemes/Fakery-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 53 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vadymmarkov/Fakery/f68f2ceaaf6782db234e4cbcd5f06dbeeb91af7e/Images/logo.png -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Licensed under the **MIT** license 2 | 3 | > Copyright (c) 2015 Vadym Markov 4 | > 5 | > Permission is hereby granted, free of charge, to any person obtaining 6 | > a copy of this software and associated documentation files (the 7 | > "Software"), to deal in the Software without restriction, including 8 | > without limitation the rights to use, copy, modify, merge, publish, 9 | > distribute, sublicense, and/or sell copies of the Software, and to 10 | > permit persons to whom the Software is furnished to do so, subject to 11 | > the following conditions: 12 | > 13 | > The above copyright notice and this permission notice shall be 14 | > included in all copies or substantial portions of the Software. 15 | > 16 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "Nimble", 6 | "repositoryURL": "https://github.com/Quick/Nimble.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "e491a6731307bb23783bf664d003be9b2fa59ab5", 10 | "version": "9.0.0" 11 | } 12 | }, 13 | { 14 | "package": "Quick", 15 | "repositoryURL": "https://github.com/Quick/Quick.git", 16 | "state": { 17 | "branch": null, 18 | "revision": "8a10ae40b78d2360ca56638f15fe721be8529993", 19 | "version": "3.1.0" 20 | } 21 | } 22 | ] 23 | }, 24 | "version": 1 25 | } 26 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "Fakery", 7 | platforms: [ 8 | .macOS(.v10_10), .iOS(.v9), .tvOS(.v9) 9 | ], 10 | products: [ 11 | .library(name: "Fakery", targets: ["Fakery"]) 12 | ], 13 | dependencies: [ 14 | // Test dependencies 15 | .package(url: "https://github.com/Quick/Quick.git", from: "3.1.2"), 16 | .package(url: "https://github.com/Quick/Nimble.git", from: "9.0.0"), 17 | ], 18 | targets: [ 19 | .target(name: "Fakery", resources: [.process("Resources")]), 20 | .testTarget(name: "FakeryTests", dependencies: ["Fakery", "Quick", "Nimble"], path: "Tests/Fakery") 21 | ] 22 | ) 23 | -------------------------------------------------------------------------------- /Project/Info-Mac.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2015 Vadym Markov. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Project/Info-Tests-Mac.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Project/Info-Tests-iOS.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Project/Info-Tests-tvOS.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Project/Info-iOS.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Project/Info-tvOS.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Fakery logo](https://raw.githubusercontent.com/vadymmarkov/Fakery/master/Images/logo.png) 2 | [![CI Status](http://img.shields.io/travis/vadymmarkov/Fakery.svg?style=flat)](https://travis-ci.org/vadymmarkov/Fakery) 3 | [![Carthage](https://img.shields.io/badge/carthage-compatible-brightgreen.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | [![Version](https://img.shields.io/cocoapods/v/Fakery.svg?style=flat)](http://cocoadocs.org/docsets/Fakery) 5 | [![License](https://img.shields.io/cocoapods/l/Fakery.svg?style=flat)](http://cocoadocs.org/docsets/Fakery) 6 | [![Platform](https://img.shields.io/cocoapods/p/Fakery.svg?style=flat)](http://cocoadocs.org/docsets/Fakery) 7 | 8 | This is a Swift port of Ruby's [Faker](https://github.com/stympy/faker) library that generates fake data. 9 | 10 | Are you still bothered with meaningless randomly character strings? Just relax and leave this job to **Fakery**. 11 | It's useful in all the cases when you need to use some dummy data for testing, population of database during development, etc. 12 | 13 | **NOTE**: Generated data is pretty realistic, supports a range of locales, but returned values are not guaranteed to be unique. 14 | 15 | ## Table of Contents 16 | 17 | * [Usage](#usage) 18 | * [Localization](#localization) 19 | * [Generators](#generators) 20 | * [Address](#address) 21 | * [App](#app) 22 | * [Business](#business) 23 | * [Cat](#cat) 24 | * [Commerce](#commerce) 25 | * [Company](#company) 26 | * [Zelda](#zelda) 27 | * [Gender](#gender) 28 | * [Internet](#internet) 29 | * [Lorem](#lorem) 30 | * [Name](#name) 31 | * [Number](#number) 32 | * [Phone number](#phone-number) 33 | * [Team](#team) 34 | * [Bank](#bank) 35 | * [Car](#car) 36 | * [Programming language](#programming-language) 37 | * [Vehicle](#vehicle) 38 | * [Hobbit](#hobbit) 39 | * [Installation](#installation) 40 | * [Contributing](#contributing) 41 | * [Author](#author) 42 | * [License](#license) 43 | 44 | ## Usage 45 | 46 | ```swift 47 | import Fakery 48 | 49 | let faker = Faker(locale: "nb-NO") 50 | 51 | let firstName = faker.name.firstName() //=> "Emilie" 52 | let lastName = faker.name.lastName() //=> "Hansen" 53 | let city = faker.address.city() //=> "Oslo" 54 | ``` 55 | 56 | ## Localization 57 | 58 | **Fakery** is quite powerful when it comes to generation of locale-specific data. 59 | In `Resources/Locales` you can find JSON files for more than 20 locales, and, of course, it's not a limit. 60 | Feel free to contribute and add more! 61 | 62 | The default locale is English. When you use one of the available generators and 63 | the corresponding key is not found in a JSON file for the currently selected 64 | locale **Fakery** will also check if it exists in "en.json" file. 65 | 66 | ## Generators 67 | 68 | ### Address 69 | 70 | ```swift 71 | 72 | faker.address.city() //=> "Oslo" 73 | faker.address.streetName() //=> "North Avenue" 74 | faker.address.secondaryAddress() //=> "Apt. 123" 75 | faker.address.streetAddress(includeSecondary: Bool) //=> "12 North Avenue" 76 | faker.address.buildingNumber() //=> "123" 77 | faker.address.postcode(stateAbbreviation: String) //=> "0884" 78 | faker.address.timeZone() //=> "America/Los_Angeles" 79 | faker.address.streetSuffix() //=> "Avenue" 80 | faker.address.citySuffix() //=> "town" 81 | faker.address.cityPrefix() //=> "North" 82 | faker.address.stateAbbreviation() //=> "CA" 83 | faker.address.state() //=> "California" 84 | faker.address.county() //=> "Autauga County" 85 | faker.address.country() //=> "United States of America" 86 | faker.address.countryCode() //=> "US" 87 | faker.address.latitude() //=> -58.17256227443719 88 | faker.address.longitude() //=> -156.65548382095133 89 | faker.address.coordinate() //=> CLLocationCoordinate2D(latitude: 40.97868, longitude: 29.09306) 90 | ``` 91 | 92 | ### App 93 | 94 | ```swift 95 | 96 | faker.app.name() //=> "Namfix" 97 | faker.app.version() //=> "0.1.1" 98 | faker.app.author() //=> "Ida Adams" 99 | ``` 100 | 101 | ### Business 102 | 103 | ```swift 104 | 105 | faker.business.creditCardNumber() //=> "1234-2121-1221-1211" 106 | faker.business.creditCardType() //=> "visa" 107 | faker.business.creditCardExpiryDate() //=> "2020-10-12" 108 | ``` 109 | 110 | ### Cat 111 | 112 | ```swift 113 | 114 | faker.cat.name() //=> "Shadow" 115 | faker.cat.breed() //=> "British Semipi-longhair" 116 | faker.cat.registry() //=> "American Cat Fanciers Association" 117 | ``` 118 | 119 | ### Commerce 120 | 121 | ```swift 122 | 123 | faker.commerce.color() //=> "black" 124 | faker.commerce.department(maximum: Int, fixedAmount: Bool) //=> "Music" 125 | faker.commerce.productName() //=> "Awesome Wooden Hat" 126 | faker.commerce.price() // 90.5 127 | ``` 128 | 129 | ### Company 130 | 131 | ```swift 132 | 133 | faker.company.name() //=> "Adams Inc" 134 | faker.company.suffix() //=> "Inc" 135 | faker.company.catchPhrase() //=> "Universal software" 136 | faker.company.bs() //=> "implement innovative methodologies" 137 | faker.company.logo() // "http://pigment.github.io/fake-logos/logos/medium/color/1.png" 138 | ``` 139 | 140 | ### Zelda 141 | 142 | ```swift 143 | 144 | faker.zelda.game() //=> "Ocarina of Time" 145 | ``` 146 | 147 | ### Gender 148 | 149 | ```swift 150 | 151 | faker.gender.type() //=> "Agender" 152 | faker.gender.binaryType() //=> "Male" 153 | ``` 154 | 155 | ### Internet 156 | 157 | ```swift 158 | 159 | faker.internet.username(separator: String?) //=> "ida4" 160 | faker.internet.domainName(alphaNumericOnly: Bool) //=> "example.com" 161 | faker.internet.domainWord(alphaNumericOnly: Bool) //=> "domainword" 162 | faker.internet.domainSuffix() //=> "com" 163 | faker.internet.email() // => "ida4@some.info" 164 | faker.internet.freeEmail() //=> "gmail.com" 165 | faker.internet.safeEmail() //=> "adams@example.org" 166 | faker.internet.password(minimumLength: Int, maximumLength: Int) //=> "e2dddhwd1g5qhvhgfi" 167 | faker.internet.ipV4Address() //=> "24.29.18.175" 168 | faker.internet.ipV6Address() //=> "ac5f:d696:3807:1d72:2eb5:4e81:7d2b:e1df" 169 | faker.internet.url() //=> "http://example.com/ida4" 170 | faker.internet.image() //=> "http://lorempixel.com/320/200" 171 | faker.internet.templateImage() //=> "http://dummyimage.com/320x200/000000/ffffff" 172 | faker.internet.hashtag() //=> "#art" 173 | 174 | ``` 175 | 176 | ### Lorem 177 | 178 | ```swift 179 | 180 | faker.lorem.word() //=> "repellendus" 181 | faker.lorem.words(amount: Int) //=> ["dolores", "adipisci", "nesciunt"] 182 | faker.lorem.character() //=> "a" 183 | faker.lorem.characters(amount: Int) // Default = 255 184 | faker.lorem.sentence(wordsAmount: Int) // Default = 4 185 | faker.lorem.sentences(amount: Int) // Default = 3 186 | faker.lorem.paragraph(sentencesAmount: Int) // Default = 3 187 | faker.lorem.paragraphs(amount: Int) // Default = 3 188 | ``` 189 | 190 | ### Name 191 | 192 | ```swift 193 | 194 | faker.name.name() //=> "Ida Adams" 195 | faker.name.firstName() //=> "Ida" 196 | faker.name.lastName() //=> "Adams" 197 | faker.name.prefix() //=> "Mrs." 198 | faker.name.suffix() //=> "PhD" 199 | faker.name.title() //=> "Lead" 200 | ``` 201 | 202 | ### Number 203 | 204 | ```swift 205 | 206 | faker.number.randomBool() //=> true or false 207 | faker.number.randomInt() //=> some Int between 0 and 1000 208 | faker.number.randomInt(min: -100, max:50) //=> some Int between -100 and 50 209 | faker.number.randomFloat() //=> some Float between 0 and 1000 210 | faker.number.randomFloat(min: -10.4, max:50) //=> some Float between -10.4 and 50 211 | faker.number.randomCGFloat() //=> some CGFloat between 0 and 1000 212 | faker.number.randomCGFloat(min: 42.42, max:86) //=> some CGFloat between -42.42 and 86 213 | faker.number.randomDouble() //=> some Double between 0 and 1000 214 | faker.number.randomDouble(min: 0, max:1) //=> some Double between 0 and 1 215 | faker.number.increasingUniqueId() //=> every call returns an unique int 216 | ``` 217 | 218 | ### Phone number 219 | 220 | ```swift 221 | 222 | faker.phoneNumber.phoneNumber() //=> "1-333-333-3333" 223 | faker.phoneNumber.cellPhone() //=> "333-333-3333" 224 | faker.phoneNumber.areaCode() //=> "201" 225 | faker.phoneNumber.exchangeCode() //=> "201" 226 | faker.phoneNumber.subscriberNumber() //=> "1234" 227 | faker.phoneNumber.numberExtension(length: Int) // "123" 228 | ``` 229 | 230 | ### Team 231 | 232 | ```swift 233 | 234 | faker.team.name() //=> "bats" 235 | faker.team.creature() //=> "Alabama bats" 236 | faker.team.state() // => "Alabama" 237 | ``` 238 | 239 | ### Bank 240 | 241 | ```swift 242 | faker.bank.name() //=> "ABN AMRO CORPORATE FINANCE LIMITED" 243 | faker.bank.swiftBic() //=> "AAFMGB21" 244 | faker.bank.iban() // => "NL45BUNQ2209931378" 245 | faker.bank.bban() //=> ABNA0136468471 246 | ``` 247 | 248 | ### Hobbit 249 | 250 | ```swift 251 | faker.hobbit.character() //=> "Bilbo Baggins" 252 | faker.hobbit.thorinsCompany() //=> "Thorin Oakenshield" 253 | faker.hobbit.quote() // => "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?" 254 | faker.hobbit.location() //=> "Bree" 255 | ``` 256 | 257 | ### Car 258 | 259 | ```swift 260 | faker.car.brand() //=> "BMW" 261 | ``` 262 | 263 | ### Programming language 264 | 265 | ```swift 266 | faker.programming_language.name() //=> "Elixir" 267 | faker.programming_language.creator() //=> "José Valim" 268 | ``` 269 | 270 | ### Vehicle 271 | 272 | ```swift 273 | faker.vehicle.manufacture() //=> "Volkswagen" 274 | faker.vehicle.make() //=> "BMW" 275 | faker.vehicle.colors() //=> "Red" 276 | ``` 277 | 278 | ### Ham 279 | 280 | ```swift 281 | faker.ham.name() //=> "Taylor Ham" 282 | ``` 283 | 284 | ### House 285 | 286 | ```swift 287 | faker.house.furniture() //=> "chair" 288 | faker.house.room() //=> "living room" 289 | ``` 290 | 291 | ## Installation 292 | 293 | **Fakery** is available through [CocoaPods](http://cocoapods.org). To install 294 | it, simply add the following line to your Podfile: 295 | 296 | ```ruby 297 | pod 'Fakery' 298 | ``` 299 | 300 | Or alternatively using the Swift Package Manager: 301 | 302 | ```swift 303 | let package = Package( 304 | //… 305 | dependencies[ 306 | .package(name: "Fakery", url: "https://github.com/vadymmarkov/Fakery", from: "5.0.0")) 307 | ], 308 | targets: [ 309 | .target(name: "Foo", dependencies: ["Fakery"] 310 | ] 311 | ) 312 | ``` 313 | 314 | Use of the Swift Package Manager requires Swift >=5.3. 315 | 316 | ## Contributing 317 | 318 | Please see our [playbook](https://github.com/hyperoslo/playbook/blob/master/GIT_AND_GITHUB.md) for guidelines on contributing. 319 | 320 | ## Author 321 | 322 | Vadym Markov, markov.vadym@gmail.com 323 | 324 | ## License 325 | 326 | **Fakery** is available under the MIT license. See the LICENSE file for more info. 327 | -------------------------------------------------------------------------------- /README.md.orig: -------------------------------------------------------------------------------- 1 | ![Fakery logo](https://raw.githubusercontent.com/vadymmarkov/Fakery/master/Images/logo.png) 2 | [![CI Status](http://img.shields.io/travis/vadymmarkov/Fakery.svg?style=flat)](https://travis-ci.org/vadymmarkov/Fakery) 3 | [![Version](https://img.shields.io/cocoapods/v/Fakery.svg?style=flat)](http://cocoadocs.org/docsets/Fakery) 4 | [![License](https://img.shields.io/cocoapods/l/Fakery.svg?style=flat)](http://cocoadocs.org/docsets/Fakery) 5 | [![Platform](https://img.shields.io/cocoapods/p/Fakery.svg?style=flat)](http://cocoadocs.org/docsets/Fakery) 6 | 7 | This is a Swift port of Ruby's [Faker](https://github.com/stympy/faker) library that generates fake data. 8 | 9 | Are you still bothered with meaningless randomly character strings? Just relax and leave this job to **Fakery**. 10 | It's useful in all the cases when you need to use some dummy data for testing, population of database during development, etc. 11 | 12 | **NOTE**: Generated data is pretty realistic, supports a range of locales, but returned values are not guaranteed to be unique. 13 | 14 | ## Table of Contents 15 | 16 | * [Usage](#usage) 17 | * [Localization](#localization) 18 | * [Generators](#generators) 19 | * [Address](#address) 20 | * [App](#app) 21 | * [Business](#business) 22 | * [Cat](#cat) 23 | * [Commerce](#commerce) 24 | * [Company](#company) 25 | * [Zelda](#zelda) 26 | * [Gender](#gender) 27 | * [Internet](#internet) 28 | * [Lorem](#lorem) 29 | * [Name](#name) 30 | * [Number](#number) 31 | * [Phone number](#phone-number) 32 | * [Team](#team) 33 | * [Bank](#bank) 34 | * [Car](#car) 35 | * [Programming language](#programming-language) 36 | * [Vehicle](#vehicle) 37 | * [Ham](#ham) 38 | * [House](#house) 39 | * [Installation](#installation) 40 | * [Contributing](#contributing) 41 | * [Author](#author) 42 | * [License](#license) 43 | 44 | ## Usage 45 | 46 | ```swift 47 | 48 | let faker = Faker(locale: "nb-NO") 49 | 50 | let firstName = faker.name.firstName() //=> "Emilie" 51 | let lastName = faker.name.lastName() //=> "Hansen" 52 | let city = faker.address.city() //=> "Oslo" 53 | ``` 54 | 55 | ## Localization 56 | 57 | **Fakery** is quite powerful when it comes to generation of locale-specific data. 58 | In `Resources/Locales` you can find JSON files for more than 20 locales, and, of course, it's not a limit. 59 | Feel free to contribute and add more! 60 | 61 | The default locale is English. When you use one of the available generators and 62 | the corresponding key is not found in a JSON file for the currently selected 63 | locale **Fakery** will also check if it exists in "en.json" file. 64 | 65 | ## Generators 66 | 67 | ### Address 68 | 69 | ```swift 70 | 71 | faker.address.city() //=> "Oslo" 72 | faker.address.streetName() //=> "North Avenue" 73 | faker.address.secondaryAddress() //=> "Apt. 123" 74 | faker.address.streetAddress(includeSecondary: Bool) //=> "12 North Avenue" 75 | faker.address.buildingNumber() //=> "123" 76 | faker.address.postcode(stateAbbreviation: String) //=> "0884" 77 | faker.address.timeZone() //=> "America/Los_Angeles" 78 | faker.address.streetSuffix() //=> "Avenue" 79 | faker.address.citySuffix() //=> "town" 80 | faker.address.cityPrefix() //=> "North" 81 | faker.address.stateAbbreviation() //=> "CA" 82 | faker.address.state() //=> "California" 83 | faker.address.county() //=> "Autauga County" 84 | faker.address.country() //=> "United States of America" 85 | faker.address.countryCode() //=> "US" 86 | faker.address.latitude() //=> -58.17256227443719 87 | faker.address.longitude() //=> -156.65548382095133 88 | faker.address.coordinate() //=> CLLocationCoordinate2D(latitude: 40.97868, longitude: 29.09306) 89 | ``` 90 | 91 | ### App 92 | 93 | ```swift 94 | 95 | faker.app.name() //=> "Namfix" 96 | faker.app.version() //=> "0.1.1" 97 | faker.app.author() //=> "Ida Adams" 98 | ``` 99 | 100 | ### Business 101 | 102 | ```swift 103 | 104 | faker.business.creditCardNumber() //=> "1234-2121-1221-1211" 105 | faker.business.creditCardType() //=> "visa" 106 | faker.business.creditCardExpiryDate() //=> "2020-10-12" 107 | ``` 108 | 109 | ### Cat 110 | 111 | ```swift 112 | 113 | faker.cat.name() //=> "Shadow" 114 | faker.cat.breed() //=> "British Semipi-longhair" 115 | faker.cat.registry() //=> "American Cat Fanciers Association" 116 | ``` 117 | 118 | ### Commerce 119 | 120 | ```swift 121 | 122 | faker.commerce.color() //=> "black" 123 | faker.commerce.department(maximum: Int, fixedAmount: Bool) //=> "Music" 124 | faker.commerce.productName() //=> "Awesome Wooden Hat" 125 | faker.commerce.price() // 90.5 126 | ``` 127 | 128 | ### Company 129 | 130 | ```swift 131 | 132 | faker.company.name() //=> "Adams Inc" 133 | faker.company.suffix() //=> "Inc" 134 | faker.company.catchPhrase() //=> "Universal software" 135 | faker.company.bs() //=> "implement innovative methodologies" 136 | faker.company.logo() // "http://pigment.github.io/fake-logos/logos/medium/color/1.png" 137 | ``` 138 | 139 | ### Zelda 140 | 141 | ```swift 142 | 143 | faker.zelda.game() //=> "Ocarina of Time" 144 | ``` 145 | 146 | ### Gender 147 | 148 | ```swift 149 | 150 | faker.gender.type() //=> "Agender" 151 | faker.gender.binaryType() //=> "Male" 152 | ``` 153 | 154 | ### Internet 155 | 156 | ```swift 157 | 158 | faker.internet.username(separator: String?) //=> "ida4" 159 | faker.internet.domainName(alphaNumericOnly: Bool) //=> "example.com" 160 | faker.internet.domainWord(alphaNumericOnly: Bool) //=> "domainword" 161 | faker.internet.domainSuffix() //=> "com" 162 | faker.internet.email() // => "ida4@some.info" 163 | faker.internet.freeEmail() //=> "gmail.com" 164 | faker.internet.safeEmail() //=> "adams@example.org" 165 | faker.internet.password(minimumLength: Int, maximumLength: Int) //=> "e2dddhwd1g5qhvhgfi" 166 | faker.internet.ipV4Address() //=> "24.29.18.175" 167 | faker.internet.ipV6Address() //=> "ac5f:d696:3807:1d72:2eb5:4e81:7d2b:e1df" 168 | faker.internet.url() //=> "http://example.com/ida4" 169 | faker.internet.image() //=> "http://lorempixel.com/320/200" 170 | faker.internet.templateImage() //=> "http://dummyimage.com/320x200/000000/ffffff" 171 | faker.internet.hashtag() //=> "#art" 172 | 173 | ``` 174 | 175 | ### Lorem 176 | 177 | ```swift 178 | 179 | faker.lorem.word() //=> "repellendus" 180 | faker.lorem.words(amount: Int) //=> ["dolores", "adipisci", "nesciunt"] 181 | faker.lorem.character() //=> "a" 182 | faker.lorem.characters(amount: Int) // Default = 255 183 | faker.lorem.sentence(wordsAmount: Int) // Default = 4 184 | faker.lorem.sentences(amount: Int) // Default = 3 185 | faker.lorem.paragraph(sentencesAmount: Int) // Default = 3 186 | faker.lorem.paragraphs(amount: Int) // Default = 3 187 | ``` 188 | 189 | ### Name 190 | 191 | ```swift 192 | 193 | faker.name.name() //=> "Ida Adams" 194 | faker.name.firstName() //=> "Ida" 195 | faker.name.lastName() //=> "Adams" 196 | faker.name.prefix() //=> "Mrs." 197 | faker.name.suffix() //=> "PhD" 198 | faker.name.title() //=> "Lead" 199 | ``` 200 | 201 | ### Number 202 | 203 | ```swift 204 | 205 | faker.number.randomBool() //=> true or false 206 | faker.number.randomInt() //=> some Int between 0 and 1000 207 | faker.number.randomInt(min: -100, max:50) //=> some Int between -100 and 50 208 | faker.number.randomFloat() //=> some Float between 0 and 1000 209 | faker.number.randomFloat(min: -10.4, max:50) //=> some Float between -10.4 and 50 210 | faker.number.randomCGFloat() //=> some CGFloat between 0 and 1000 211 | faker.number.randomCGFloat(min: 42.42, max:86) //=> some CGFloat between -42.42 and 86 212 | faker.number.randomDouble() //=> some Double between 0 and 1000 213 | faker.number.randomDouble(min: 0, max:1) //=> some Double between 0 and 1 214 | faker.number.increasingUniqueId() //=> every call returns an unique int 215 | ``` 216 | 217 | ### Phone number 218 | 219 | ```swift 220 | 221 | faker.phoneNumber.phoneNumber() //=> "1-333-333-3333" 222 | faker.phoneNumber.cellPhone() //=> "333-333-3333" 223 | faker.phoneNumber.areaCode() //=> "201" 224 | faker.phoneNumber.exchangeCode() //=> "201" 225 | faker.phoneNumber.subscriberNumber() //=> "1234" 226 | faker.phoneNumber.numberExtension(length: Int) // "123" 227 | ``` 228 | 229 | ### Team 230 | 231 | ```swift 232 | 233 | faker.team.name() //=> "bats" 234 | faker.team.creature() //=> "Alabama bats" 235 | faker.team.state() // => "Alabama" 236 | ``` 237 | 238 | ### Bank 239 | 240 | ```swift 241 | faker.bank.name() //=> "ABN AMRO CORPORATE FINANCE LIMITED" 242 | faker.bank.swiftBic() //=> "AAFMGB21" 243 | faker.bank.iban() // => "NL45BUNQ2209931378" 244 | faker.bank.bban() //=> ABNA0136468471 245 | ``` 246 | 247 | ### Hobbit 248 | 249 | ```swift 250 | faker.hobbit.character() //=> "Bilbo Baggins" 251 | faker.hobbit.thorinsCompany() //=> "Thorin Oakenshield" 252 | faker.hobbit.quote() // => "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?" 253 | faker.hobbit.location() //=> "Bree" 254 | ``` 255 | 256 | ### Car 257 | 258 | ```swift 259 | faker.car.brand() //=> "BMW" 260 | ``` 261 | 262 | ### Programming language 263 | 264 | ```swift 265 | faker.programming_language.name() //=> "Elixir" 266 | faker.programming_language.creator() //=> "José Valim" 267 | ``` 268 | 269 | ### Vehicle 270 | 271 | ```swift 272 | faker.vehicle.manufacture() //=> "Volkswagen" 273 | faker.vehicle.make() //=> "BMW" 274 | faker.vehicle.colors() //=> "Red" 275 | ``` 276 | 277 | ### Ham 278 | 279 | ```swift 280 | faker.ham.name() //=> "Taylor Ham" 281 | ``` 282 | 283 | ### House 284 | 285 | ```swift 286 | faker.house.furniture() //=> "chair" 287 | faker.house.room() //=> "living room" 288 | ``` 289 | 290 | ## Installation 291 | 292 | **Fakery** is available through [CocoaPods](http://cocoapods.org). To install 293 | it, simply add the following line to your Podfile: 294 | 295 | ```ruby 296 | pod 'Fakery' 297 | ``` 298 | 299 | ## Contributing 300 | 301 | Please see our [playbook](https://github.com/hyperoslo/playbook/blob/master/GIT_AND_GITHUB.md) for guidelines on contributing. 302 | 303 | ## Author 304 | 305 | Vadym Markov, markov.vadym@gmail.com 306 | 307 | ## License 308 | 309 | **Fakery** is available under the MIT license. See the LICENSE file for more info. 310 | -------------------------------------------------------------------------------- /Resources: -------------------------------------------------------------------------------- 1 | Sources/Fakery/Resources -------------------------------------------------------------------------------- /Sources/Fakery/Config.swift: -------------------------------------------------------------------------------- 1 | public struct Config { 2 | public static let defaultLocale: String = "en" 3 | public static let pathExtension: String = "json" 4 | public static var dirPath: String = "Resources/Locales" 5 | public static var dirFrameworkPath: String = "" 6 | public static var dirResourcePath: String = "" 7 | } 8 | -------------------------------------------------------------------------------- /Sources/Fakery/Data/Parser.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public final class Parser { 4 | public var locale: String { 5 | didSet { 6 | if locale != oldValue { 7 | loadData(forLocale: locale) 8 | } 9 | } 10 | } 11 | 12 | private var data = [String: Any]() 13 | let provider: Provider 14 | 15 | // MARK: - Initialization 16 | 17 | public init(locale: String = Config.defaultLocale) { 18 | self.locale = locale 19 | provider = Provider() 20 | loadData(forLocale: locale) 21 | 22 | if locale != Config.defaultLocale { 23 | loadData(forLocale: Config.defaultLocale) 24 | } 25 | } 26 | 27 | // MARK: - Parsing 28 | 29 | public func fetch(_ key: String) -> String { 30 | var parsed = "" 31 | 32 | guard let keyData = fetchRaw(key) else { 33 | return parsed 34 | } 35 | 36 | let subject = getSubject(key) 37 | 38 | if let value = keyData as? String { 39 | parsed = value 40 | } else if let array = keyData as? [String], let item = array.random() { 41 | parsed = item 42 | } 43 | 44 | if parsed.range(of: "#{") != nil { 45 | parsed = parse(parsed, forSubject: subject) 46 | } 47 | 48 | return parsed 49 | } 50 | 51 | public func fetchRaw(_ key: String) -> Any? { 52 | let result = fetchRaw(key, forLocale: locale) 53 | 54 | guard locale != Config.defaultLocale else { 55 | return result 56 | } 57 | 58 | return result ?? fetchRaw(key, forLocale: Config.defaultLocale) 59 | } 60 | 61 | func parse(_ template: String, forSubject subject: String) -> String { 62 | var text = "" 63 | let string = NSString(string: template) 64 | var regex: NSRegularExpression 65 | 66 | do { 67 | try regex = NSRegularExpression(pattern: "(\\(?)#\\{([A-Za-z]+\\.)?([^\\}]+)\\}([^#]+)?", 68 | options: .caseInsensitive) 69 | 70 | let matches = regex.matches(in: template, 71 | options: .reportCompletion, 72 | range: NSRange(location: 0, length: string.length)) 73 | 74 | guard !matches.isEmpty else { 75 | return template 76 | } 77 | 78 | for match in matches { 79 | if match.numberOfRanges < 4 { 80 | continue 81 | } 82 | 83 | let prefixRange = match.range(at: 1) 84 | let subjectRange = match.range(at: 2) 85 | let methodRange = match.range(at: 3) 86 | let otherRange = match.range(at: 4) 87 | 88 | if prefixRange.length > 0 { 89 | text += string.substring(with: prefixRange) 90 | } 91 | 92 | var subjectWithDot = subject + "." 93 | 94 | if subjectRange.length > 0 { 95 | subjectWithDot = string.substring(with: subjectRange) 96 | } 97 | 98 | if methodRange.length > 0 { 99 | let key = subjectWithDot.lowercased() + string.substring(with: methodRange) 100 | text += fetch(key) 101 | } 102 | 103 | if otherRange.length > 0 { 104 | text += string.substring(with: otherRange) 105 | } 106 | } 107 | } catch {} 108 | 109 | return text 110 | } 111 | 112 | private func fetchRaw(_ key: String, forLocale locale: String) -> Any? { 113 | let parts = key.components(separatedBy: ".") 114 | 115 | guard let localeData = data[locale] as? [String: Any], 116 | var parsed = localeData["faker"] as? [String: Any], 117 | !parts.isEmpty else { return nil } 118 | 119 | var result: Any? 120 | 121 | for part in parts { 122 | guard let parsedPart = parsed[part] as? [String: Any] else { 123 | result = parsed[part] 124 | continue 125 | } 126 | 127 | parsed = parsedPart 128 | result = parsedPart 129 | } 130 | 131 | return result 132 | } 133 | 134 | private func getSubject(_ key: String) -> String { 135 | var subject: String = "" 136 | let parts = key.components(separatedBy: ".") 137 | 138 | if !parts.isEmpty { 139 | subject = parts[0] 140 | } 141 | 142 | return subject 143 | } 144 | 145 | // MARK: - Data loading 146 | 147 | private func loadData(forLocale locale: String) { 148 | guard let localeData = provider.dataForLocale(locale), 149 | let parsedData = try? JSONSerialization.jsonObject(with: localeData, options: .allowFragments), 150 | let json = parsedData as? [String: Any], 151 | let localeJson = json[locale] else { 152 | print("JSON file for '\(locale)' locale was not found.") 153 | return 154 | } 155 | 156 | data[locale] = localeJson 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /Sources/Fakery/Data/Provider.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public final class Provider { 4 | var translations: [String: Data] = [:] 5 | 6 | // MARK: - Locale data 7 | 8 | public func dataForLocale(_ locale: String) -> Data? { 9 | var translation: Data? 10 | 11 | if let translationData = translations[locale] { 12 | translation = translationData 13 | } else { 14 | #if SWIFT_PACKAGE 15 | let bundle = Bundle.module 16 | #else 17 | let bundle = Bundle(for: Provider.self) 18 | #endif 19 | 20 | var path = bundle.path(forResource: locale, 21 | ofType: Config.pathExtension, 22 | inDirectory: Config.dirPath) ?? 23 | bundle.path(forResource: locale, 24 | ofType: Config.pathExtension, 25 | inDirectory: Config.dirFrameworkPath) 26 | 27 | if !Config.dirResourcePath.isEmpty { 28 | path = "\(Config.dirResourcePath)/\(locale).\(Config.pathExtension)" 29 | } 30 | 31 | if let resourcePath = Bundle(for: Provider.self).resourcePath { 32 | let bundlePath = resourcePath + "/Faker.bundle" 33 | 34 | if let bundle = Bundle(path: bundlePath) { 35 | path = bundle.path(forResource: locale, ofType: Config.pathExtension) 36 | } 37 | } 38 | 39 | if let path = path { 40 | let fileURL = URL(fileURLWithPath: path) 41 | 42 | if let data = try? Data(contentsOf: fileURL) { 43 | translation = data 44 | translations[locale] = data 45 | } 46 | } 47 | } 48 | 49 | return translation 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Sources/Fakery/Extensions/ArrayExtension.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Array { 4 | func at(_ index: Int?) -> Element? { 5 | guard let index = index, index >= 0 && index < endIndex else { 6 | return nil 7 | } 8 | 9 | return self[index] 10 | } 11 | 12 | func random() -> Element? { 13 | // swiftlint:disable empty_count 14 | guard count > 0 else { 15 | return nil 16 | } 17 | #if swift(>=4.2) 18 | return self.randomElement() 19 | #else 20 | return self[Int(arc4random_uniform(UInt32(count)))] 21 | #endif 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/Fakery/Extensions/StringExtensions.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension String { 4 | static func characters(amount: Int = 255) -> String { 5 | var chars = "" 6 | 7 | if amount > 0 { 8 | for _ in 0..=4.2) 10 | let char = Character(UnicodeScalar(Int.random(in: 0.. String { 15 | return generate("address.city") 16 | } 17 | 18 | public func streetName() -> String { 19 | return generate("address.street_name") 20 | } 21 | 22 | public func secondaryAddress() -> String { 23 | return numerify(generate("address.secondary_address")) 24 | } 25 | 26 | public func streetAddress(includeSecondary: Bool = false) -> String { 27 | var streetAddress = numerify(generate("address.street_address")) 28 | 29 | if includeSecondary { 30 | streetAddress += " " + secondaryAddress() 31 | } 32 | 33 | return streetAddress 34 | } 35 | 36 | public func buildingNumber() -> String { 37 | return bothify(generate("address.building_number")) 38 | } 39 | 40 | public func postcode(stateAbbreviation: String = "") -> String { 41 | if stateAbbreviation.isEmpty { 42 | return bothify(generate("address.postcode")) 43 | } 44 | 45 | return bothify(generate("address.postcode_by_state.\(stateAbbreviation)")) 46 | } 47 | 48 | public func timeZone() -> String { 49 | return generate("address.time_zone") 50 | } 51 | 52 | public func streetSuffix() -> String { 53 | return generate("address.street_suffix") 54 | } 55 | 56 | public func citySuffix() -> String { 57 | return generate("address.city_suffix") 58 | } 59 | 60 | public func cityPrefix() -> String { 61 | return generate("address.city_prefix") 62 | } 63 | 64 | public func stateAbbreviation() -> String { 65 | return generate("address.state_abbr") 66 | } 67 | 68 | public func state() -> String { 69 | return generate("address.state") 70 | } 71 | 72 | public func county() -> String { 73 | return generate("address.county") 74 | } 75 | 76 | public func country() -> String { 77 | return generate("address.country") 78 | } 79 | 80 | public func countryCode() -> String { 81 | return generate("address.country_code") 82 | } 83 | 84 | public func latitude() -> Double { 85 | return drand48() * 180.0 - 90.0 86 | } 87 | 88 | public func longitude() -> Double { 89 | return drand48() * 360.0 - 180.0 90 | } 91 | 92 | public func coordinate(inRadius radius: Double, fromCenter center: Location) -> Location { 93 | let y0 = center.latitude 94 | let x0 = center.longitude 95 | 96 | // Convert meters to degrees for radius 97 | let radiusInDegrees = radius / 111300.0 98 | 99 | // Random point in circle 100 | #if swift(>=4.2) 101 | let rhoRandom = Double.random(in: 0.. String { 4 | return generate("app.name") 5 | } 6 | 7 | public func version() -> String { 8 | return numerify(generate("app.version")) 9 | } 10 | 11 | public func author() -> String { 12 | return generate("app.author") 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Bank.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class Bank: Generator { 3 | public func name() -> String { 4 | return generate("bank.name") 5 | } 6 | 7 | public func swiftBic() -> String { 8 | return generate("bank.swiftBic") 9 | } 10 | 11 | public func iban() -> String { 12 | let bankCountryCode = generate("bank.ibanDetails.bankCountryCode") 13 | let bankCountryString = numerify("##") 14 | let ibanLetterCode = letterify(generate("bank.ibanDetails.ibanLetterCode")) 15 | let iban = numerify(generate("bank.ibanDetails.ibanDigits")) 16 | 17 | return bankCountryCode + bankCountryString + ibanLetterCode + iban 18 | } 19 | 20 | public func bban() -> String { 21 | let ibanLetterCode: String = letterify(generate("bank.ibanDetails.ibanLetterCode")) 22 | let iban: String = numerify(generate("bank.ibanDetails.ibanDigits")) 23 | 24 | return ibanLetterCode + iban 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Business.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Business: Generator { 5 | public func creditCardNumber() -> String { 6 | return generate("business.credit_card_numbers") 7 | } 8 | 9 | public func creditCardType() -> String { 10 | return generate("business.credit_card_types") 11 | } 12 | 13 | public func creditCardExpiryDate() -> Foundation.Date? { 14 | let dateString = generate("business.credit_card_expiry_dates") 15 | return dateFormatter.date(from: dateString) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Car.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Car: Generator { 5 | public func brand() -> String { 6 | return generate("car.brand") 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Cat.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Cat: Generator { 5 | public func name() -> String { 6 | return generate("cat.name") 7 | } 8 | 9 | public func breed() -> String { 10 | return generate("cat.breed") 11 | } 12 | 13 | public func registry() -> String { 14 | return generate("cat.registry") 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Commerce.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Commerce: Generator { 5 | public func color() -> String { 6 | return generate("commerce.color") 7 | } 8 | 9 | public func department(maximum: Int = 3, fixedAmount: Bool = false) -> String { 10 | #if swift(>=4.2) 11 | let amount = fixedAmount ? maximum : 1 + Int.random(in: 0.. 1 { 21 | department = merge(categories: fetchedCategories) 22 | } else if count == 1 { 23 | department = fetchedCategories[0] 24 | } 25 | 26 | return department 27 | } 28 | 29 | public func productName() -> String { 30 | return generate("commerce.product_name.adjective") + " " 31 | + generate("commerce.product_name.material") + " " 32 | + generate("commerce.product_name.product") 33 | } 34 | 35 | public func price() -> Double { 36 | let arc4randoMax: Double = 0x100000000 37 | #if swift(>=4.2) 38 | return floor(Double((Double(UInt32.random(in: 0.. [String] { 47 | var categories: [String] = [] 48 | 49 | while categories.count < amount { 50 | let category = generate("commerce.department") 51 | 52 | if !categories.contains(category) { 53 | categories.append(category) 54 | } 55 | } 56 | 57 | return categories 58 | } 59 | 60 | public func merge(categories: [String]) -> String { 61 | let separator = generate("separator") 62 | let commaSeparated = categories[0.. String { 6 | return generate("company.name") 7 | } 8 | 9 | public func suffix() -> String { 10 | return generate("company.suffix") 11 | } 12 | 13 | public func catchPhrase() -> String { 14 | return randomWordsFromKey("company.buzzwords") 15 | } 16 | 17 | public func bs() -> String { 18 | return randomWordsFromKey("company.bs") 19 | } 20 | 21 | public func logo() -> String { 22 | #if swift(>=4.2) 23 | let number = Int.random(in: 0..<13) + 1 24 | #else 25 | let number = Int(arc4random_uniform(13)) + 1 26 | #endif 27 | return "https://pigment.github.io/fake-logos/logos/medium/color/\(number).png" 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Date.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Date: Generator { 5 | 6 | private let number: Number 7 | 8 | public required init(parser: Parser) { 9 | self.number = Number(parser: parser) 10 | super.init(parser: parser) 11 | } 12 | 13 | public func backward(days: Int) -> Foundation.Date { 14 | return todayAddingDays(-days) 15 | } 16 | 17 | public func forward(_ days: Int) -> Foundation.Date { 18 | return todayAddingDays(days) 19 | } 20 | 21 | public func between(_ from: Foundation.Date, _ to: Foundation.Date) -> Foundation.Date { 22 | let fromInSeconds = from.timeIntervalSince1970 23 | let toInSeconds = to.timeIntervalSince1970 24 | let targetInSeconds = number.randomDouble(min: fromInSeconds, max: toInSeconds) 25 | return Foundation.Date(timeIntervalSince1970: targetInSeconds) 26 | } 27 | 28 | public func birthday(_ minAge: Int, _ maxAge: Int) -> Foundation.Date { 29 | let olderAgeBirthDate = todayAddingYears(-maxAge) 30 | let earlierAgeBirthDate = todayAddingYears(-minAge) 31 | return between(earlierAgeBirthDate, olderAgeBirthDate) 32 | } 33 | 34 | private func todayAddingDays(_ days: Int) -> Foundation.Date { 35 | var dateComponents = DateComponents() 36 | dateComponents.day = days 37 | return todayAdding(dateComponents) 38 | } 39 | 40 | private func todayAddingYears(_ years: Int) -> Foundation.Date { 41 | var dateComponents = DateComponents() 42 | dateComponents.year = years 43 | return todayAdding(dateComponents) 44 | } 45 | 46 | private func todayAdding(_ dateComponents: DateComponents) -> Foundation.Date { 47 | let calendar = Calendar.current 48 | 49 | let todayDate = Foundation.Date() 50 | return calendar.date(byAdding: dateComponents, to: todayDate)! 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Gender.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Gender: Generator { 5 | public func type() -> String { 6 | return generate("gender.type") 7 | } 8 | 9 | public func binaryType() -> String { 10 | return generate("gender.binary_type") 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Generator.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public class Generator { 5 | // swiftlint:disable nesting 6 | public struct Constants { 7 | public static let uppercaseLetters = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZ") 8 | public static let letters = Array("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 9 | public static let numbers = Array("0123456789") 10 | } 11 | 12 | let parser: Parser 13 | let dateFormatter: DateFormatter 14 | 15 | public required init(parser: Parser) { 16 | self.parser = parser 17 | dateFormatter = DateFormatter() 18 | dateFormatter.dateFormat = "yyyy-MM-dd" 19 | } 20 | 21 | public func generate(_ key: String) -> String { 22 | return parser.fetch(key) 23 | } 24 | 25 | // MARK: - Filling 26 | 27 | public func numerify(_ string: String) -> String { 28 | let count = UInt32(Constants.numbers.count) 29 | 30 | return String(string.enumerated().map { (index, item) in 31 | #if swift(>=4.2) 32 | let numberIndex = index == 0 ? UInt32.random(in: 0..<(count - 1)) : UInt32.random(in: 0.. String { 42 | return String(string.enumerated().map { _, item in 43 | #if swift(>=4.2) 44 | let char = Constants.uppercaseLetters.randomElement() ?? Character("") 45 | #else 46 | let count = UInt32(Constants.uppercaseLetters.count) 47 | let char = Constants.uppercaseLetters[Int(arc4random_uniform(count))] 48 | #endif 49 | return String(item) == "?" ? char : item 50 | }) 51 | } 52 | 53 | public func bothify(_ string: String) -> String { 54 | return letterify(numerify(string)) 55 | } 56 | 57 | public func alphaNumerify(_ string: String) -> String { 58 | return string.replacingOccurrences(of: "[^A-Za-z0-9_]", 59 | with: "", 60 | options: .regularExpression, 61 | range: nil) 62 | } 63 | 64 | public func randomWordsFromKey(_ key: String) -> String { 65 | var string = "" 66 | 67 | var list = [String]() 68 | if let wordsList = parser.fetchRaw(key) as? [[String]] { 69 | for words in wordsList { 70 | if let item = words.random() { 71 | list.append(item) 72 | } 73 | } 74 | 75 | string = list.joined(separator: " ") 76 | } 77 | 78 | return string 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Ham.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class Ham: Generator { 3 | public func name() -> String { 4 | return generate("ham.name") 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Hobbit.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Hobbit: Generator { 5 | public func character() -> String { 6 | return generate("hobbit.character") 7 | } 8 | 9 | public func thorinsCompany() -> String { 10 | return generate("hobbit.thorins_company") 11 | } 12 | 13 | public func quote() -> String { 14 | return generate("hobbit.quote") 15 | } 16 | 17 | public func location() -> String { 18 | return generate("hobbit.location") 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/House.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class House: Generator { 3 | public func furniture() -> String { 4 | return generate("house.furniture") 5 | } 6 | 7 | public func room() -> String { 8 | return generate("house.room") 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Internet.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Internet: Generator { 5 | public required init(parser: Parser) { 6 | super.init(parser: parser) 7 | } 8 | 9 | public func username(separator: String? = nil) -> String { 10 | #if swift(>=4.2) 11 | let lastRandomComponent = Int.random(in: 0..<10000) 12 | #else 13 | let lastRandomComponent = arc4random_uniform(10000) 14 | #endif 15 | let components: [String] = [ 16 | generate("name.first_name"), 17 | generate("name.last_name"), 18 | "\(lastRandomComponent)" 19 | ] 20 | 21 | let randomCount = components.count - 1 22 | #if swift(>=4.2) 23 | let count = Int.random(in: 0.. String { 39 | return domainWord(alphaNumericOnly: alphaNumericOnly) + "." + domainSuffix() 40 | } 41 | 42 | public func domainWord(alphaNumericOnly: Bool = true) -> String { 43 | let nameParts = generate("company.name").components(separatedBy: " ") 44 | var name = "" 45 | 46 | if let first = nameParts.first { 47 | name = first 48 | } else { 49 | name = letterify("?????") 50 | } 51 | 52 | let result = alphaNumericOnly ? alphaNumerify(name) : name 53 | 54 | return result.lowercased() 55 | } 56 | 57 | public func domainSuffix() -> String { 58 | return generate("internet.domain_suffix") 59 | } 60 | 61 | public func email() -> String { 62 | return [username(), domainName()].joined(separator: "@") 63 | } 64 | 65 | public func freeEmail() -> String { 66 | return [username(), generate("internet.free_email")].joined(separator: "@") 67 | } 68 | 69 | public func safeEmail() -> String { 70 | let topLevelDomains = ["org", "com", "net"] 71 | #if swift(>=4.2) 72 | let topLevelDomain = topLevelDomains.randomElement() ?? "" 73 | #else 74 | let count = UInt32(topLevelDomains.count) 75 | let topLevelDomain = topLevelDomains[Int(arc4random_uniform(count))] 76 | #endif 77 | 78 | return [username(), "example." + topLevelDomain].joined(separator: "@") 79 | } 80 | 81 | public func password(minimumLength: Int = 8, maximumLength: Int = 16) -> String { 82 | var temp = String.characters(amount: minimumLength) 83 | let diffLength = maximumLength - minimumLength 84 | 85 | if diffLength > 0 { 86 | #if swift(>=4.2) 87 | let diffRandom = Int.random(in: 0.. String { 98 | #if swift(>=4.2) 99 | let randomNumber = UInt32.random(in: 0.. String { 111 | #if swift(>=4.2) 112 | let randomNumber = UInt32.random(in: 0.. String { 127 | return "https://\(domainName())/\(username())" 128 | } 129 | 130 | public func image(width: Int = 320, height: Int = 200) -> String { 131 | return "https://lorempixel.com/\(width)/\(height)" 132 | } 133 | 134 | public func templateImage(width: Int = 320, height: Int = 200, 135 | backColorHex: String = "000000", frontColorHex: String = "ffffff") -> String { 136 | return "https://dummyimage.com/\(width)x\(height)/\(backColorHex)/\(frontColorHex)" 137 | } 138 | 139 | public func hashtag() -> String { 140 | return generate("internet.hashtag") 141 | } 142 | 143 | // @ToDo - slug 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Lorem.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Faker { 4 | public final class Lorem: Generator { 5 | public func word() -> String { 6 | return generate("lorem.words") 7 | } 8 | 9 | public func words(amount: Int = 3) -> String { 10 | var words: [String] = [] 11 | 12 | for _ in 0.. String { 20 | return characters(amount: 1) 21 | } 22 | 23 | public func characters(amount: Int = 255) -> String { 24 | return String.characters(amount: amount) 25 | } 26 | 27 | public func sentence(wordsAmount: Int = 4) -> String { 28 | var sentence = words(amount: wordsAmount) + "." 29 | sentence.replaceSubrange(sentence.startIndex...sentence.startIndex, 30 | with: String(sentence[sentence.startIndex]).capitalized) 31 | return sentence 32 | } 33 | 34 | public func sentences(amount: Int = 3) -> String { 35 | var sentences: [String] = [] 36 | 37 | for _ in 0.. String { 45 | return sentences(amount: sentencesAmount) 46 | } 47 | 48 | public func paragraphs(amount: Int = 3) -> String { 49 | var paragraphs: [String] = [] 50 | 51 | for _ in 0.. String { 4 | return generate("name.name") 5 | } 6 | 7 | public func firstName() -> String { 8 | return generate("name.first_name") 9 | } 10 | 11 | public func lastName() -> String { 12 | return generate("name.last_name") 13 | } 14 | 15 | public func prefix() -> String { 16 | return generate("name.prefix") 17 | } 18 | 19 | public func suffix() -> String { 20 | return generate("name.suffix") 21 | } 22 | 23 | public func title() -> String { 24 | return generate("name.title.descriptor") + " " 25 | + generate("name.title.level") + " " 26 | + generate("name.title.job") 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Number.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | #if !os(Linux) 3 | import CoreGraphics 4 | #endif 5 | 6 | extension Faker { 7 | public final class Number: Generator { 8 | fileprivate var lastUsedId: Int64 = 0 9 | 10 | public func randomBool() -> Bool { 11 | return randomInt() % 2 == 0 12 | } 13 | 14 | public func randomInt(min: Int = 0, max: Int = 1000) -> Int { 15 | var rand: Int = 0 16 | #if swift(>=4.2) 17 | rand = Int.random(in: rand..= 0 && max - Int.max >= min { 24 | return min + rand 25 | } 26 | 27 | return min + (rand % (max - min)) 28 | } 29 | 30 | public func randomFloat(min: Float = 0, max: Float = 1000) -> Float { 31 | #if swift(>=4.2) 32 | return (Float.random(in: 0.. CGFloat { 40 | return CGFloat(Float(arc4random()) / Float(UInt32.max)) * (max - min) + min 41 | } 42 | #endif 43 | 44 | public func randomDouble(min: Double = 0, max: Double = 1000) -> Double { 45 | #if swift(>=4.2) 46 | return (Double.random(in: 0.. Int { 54 | #if os(Linux) 55 | // increasing just by one on linux due to the lack of an method like OSAtomicIncrement64 56 | lastUsedId += 1 57 | #else 58 | OSAtomicIncrement64(&lastUsedId) 59 | #endif 60 | return Int(lastUsedId) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/PhoneNumber.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class PhoneNumber: Generator { 3 | public func phoneNumber() -> String { 4 | return numerify(generate("phone_number.formats")) 5 | } 6 | 7 | public func cellPhone() -> String { 8 | return numerify(generate("cell_phone.formats")) 9 | } 10 | 11 | // US only 12 | public func areaCode() -> String { 13 | return generate("phone_number.area_code") 14 | } 15 | 16 | // US only 17 | public func exchangeCode() -> String { 18 | return generate("phone_number.exchange_code") 19 | } 20 | 21 | // US only 22 | public func subscriberNumber() -> String { 23 | return numerify("####") 24 | } 25 | 26 | public func numberExtension(_ length: Int) -> String { 27 | var template = "" 28 | 29 | for _ in 1...length { 30 | template += "#" 31 | } 32 | 33 | return numerify(template) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/ProgrammingLanguage.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class ProgrammingLanguage: Generator { 3 | public func name() -> String { 4 | return generate("programming_language.name") 5 | } 6 | 7 | public func creator() -> String { 8 | return generate("programming_language.creator") 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Team.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class Team: Generator { 3 | public func name() -> String { 4 | return generate("team.name") 5 | } 6 | 7 | public func creature() -> String { 8 | return generate("team.creature") 9 | } 10 | 11 | public func state() -> String { 12 | return generate("address.state").capitalized 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Vehicle.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class Vehicle: Generator { 3 | public func manufacture() -> String { 4 | return generate("vehicle.manufacture") 5 | } 6 | 7 | public func make() -> String { 8 | return generate("vehicle.makes") 9 | } 10 | 11 | public func colors() -> String { 12 | return generate("vehicle.colors") 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/Fakery/Generators/Zelda.swift: -------------------------------------------------------------------------------- 1 | extension Faker { 2 | public final class Zelda: Generator { 3 | public func game() -> String { 4 | return generate("zelda.game") 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/de-CH.json: -------------------------------------------------------------------------------- 1 | { 2 | "de-CH": { 3 | "faker": { 4 | "address": { 5 | "country_code": [ 6 | "CH", 7 | "CH", 8 | "CH", 9 | "DE", 10 | "AT", 11 | "US", 12 | "LI", 13 | "US", 14 | "HK", 15 | "VN" 16 | ], 17 | "postcode": [ 18 | "1###", 19 | "2###", 20 | "3###", 21 | "4###", 22 | "5###", 23 | "6###", 24 | "7###", 25 | "8###", 26 | "9###" 27 | ], 28 | "default_country": [ 29 | "Schweiz" 30 | ] 31 | }, 32 | "company": { 33 | "suffix": [ 34 | "AG", 35 | "GmbH", 36 | "und Söhne", 37 | "und Partner", 38 | "& Co.", 39 | "Gruppe", 40 | "LLC", 41 | "Inc." 42 | ], 43 | "name": [ 44 | "#{Name.last_name} #{suffix}", 45 | "#{Name.last_name}-#{Name.last_name}", 46 | "#{Name.last_name}, #{Name.last_name} und #{Name.last_name}" 47 | ] 48 | }, 49 | "internet": { 50 | "domain_suffix": [ 51 | "com", 52 | "net", 53 | "biz", 54 | "ch", 55 | "de", 56 | "li", 57 | "at", 58 | "ch", 59 | "ch" 60 | ] 61 | }, 62 | "phone_number": { 63 | "formats": [ 64 | "0800 ### ###", 65 | "0800 ## ## ##", 66 | "0## ### ## ##", 67 | "0## ### ## ##", 68 | "+41 ## ### ## ##", 69 | "0900 ### ###", 70 | "076 ### ## ##", 71 | "+4178 ### ## ##", 72 | "0041 79 ### ## ##" 73 | ] 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/en-CA.json: -------------------------------------------------------------------------------- 1 | { 2 | "en-CA": { 3 | "faker": { 4 | "address": { 5 | "postcode": "/[A-CEJ-NPR-TVXY][0-9][A-CEJ-NPR-TV-Z] ?[0-9][A-CEJ-NPR-TV-Z][0-9]/", 6 | "state": [ 7 | "Alberta", 8 | "British Columbia", 9 | "Manitoba", 10 | "New Brunswick", 11 | "Newfoundland and Labrador", 12 | "Nova Scotia", 13 | "Northwest Territories", 14 | "Nunavut", 15 | "Ontario", 16 | "Prince Edward Island", 17 | "Quebec", 18 | "Saskatchewan", 19 | "Yukon" 20 | ], 21 | "state_abbr": [ 22 | "AB", 23 | "BC", 24 | "MB", 25 | "NB", 26 | "NL", 27 | "NS", 28 | "NU", 29 | "NT", 30 | "ON", 31 | "PE", 32 | "QC", 33 | "SK", 34 | "YT" 35 | ], 36 | "default_country": [ 37 | "Canada" 38 | ] 39 | }, 40 | "internet": { 41 | "free_email": [ 42 | "gmail.com", 43 | "yahoo.ca", 44 | "hotmail.com" 45 | ], 46 | "domain_suffix": [ 47 | "ca", 48 | "com", 49 | "biz", 50 | "info", 51 | "name", 52 | "net", 53 | "org" 54 | ] 55 | }, 56 | "phone_number": { 57 | "formats": [ 58 | "###-###-####", 59 | "(###)###-####", 60 | "###.###.####", 61 | "1-###-###-####", 62 | "###-###-#### x###", 63 | "(###)###-#### x###", 64 | "1-###-###-#### x###", 65 | "###.###.#### x###", 66 | "###-###-#### x####", 67 | "(###)###-#### x####", 68 | "1-###-###-#### x####", 69 | "###.###.#### x####", 70 | "###-###-#### x#####", 71 | "(###)###-#### x#####", 72 | "1-###-###-#### x#####", 73 | "###.###.#### x#####" 74 | ] 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/en-GB.json: -------------------------------------------------------------------------------- 1 | { 2 | "en-GB": { 3 | "faker": { 4 | "address": { 5 | "postcode": "/[A-PR-UWYZ][A-HK-Y]?[0-9][ABEHMNPRVWXY0-9]? [0-9][ABD-HJLN-UW-Z]{2}/", 6 | "county": [ 7 | "Avon", 8 | "Bedfordshire", 9 | "Berkshire", 10 | "Borders", 11 | "Buckinghamshire", 12 | "Cambridgeshire", 13 | "Central", 14 | "Cheshire", 15 | "Cleveland", 16 | "Clwyd", 17 | "Cornwall", 18 | "County Antrim", 19 | "County Armagh", 20 | "County Down", 21 | "County Fermanagh", 22 | "County Londonderry", 23 | "County Tyrone", 24 | "Cumbria", 25 | "Derbyshire", 26 | "Devon", 27 | "Dorset", 28 | "Dumfries and Galloway", 29 | "Durham", 30 | "Dyfed", 31 | "East Sussex", 32 | "Essex", 33 | "Fife", 34 | "Gloucestershire", 35 | "Grampian", 36 | "Greater Manchester", 37 | "Gwent", 38 | "Gwynedd County", 39 | "Hampshire", 40 | "Herefordshire", 41 | "Hertfordshire", 42 | "Highlands and Islands", 43 | "Humberside", 44 | "Isle of Wight", 45 | "Kent", 46 | "Lancashire", 47 | "Leicestershire", 48 | "Lincolnshire", 49 | "Lothian", 50 | "Merseyside", 51 | "Mid Glamorgan", 52 | "Norfolk", 53 | "North Yorkshire", 54 | "Northamptonshire", 55 | "Northumberland", 56 | "Nottinghamshire", 57 | "Oxfordshire", 58 | "Powys", 59 | "Rutland", 60 | "Shropshire", 61 | "Somerset", 62 | "South Glamorgan", 63 | "South Yorkshire", 64 | "Staffordshire", 65 | "Strathclyde", 66 | "Suffolk", 67 | "Surrey", 68 | "Tayside", 69 | "Tyne and Wear", 70 | "Warwickshire", 71 | "West Glamorgan", 72 | "West Midlands", 73 | "West Sussex", 74 | "West Yorkshire", 75 | "Wiltshire", 76 | "Worcestershire" 77 | ], 78 | "uk_country": [ 79 | "England", 80 | "Scotland", 81 | "Wales", 82 | "Northern Ireland" 83 | ], 84 | "default_country": [ 85 | "England", 86 | "Scotland", 87 | "Wales", 88 | "Northern Ireland" 89 | ] 90 | }, 91 | "internet": { 92 | "domain_suffix": [ 93 | "co.uk", 94 | "com", 95 | "biz", 96 | "info", 97 | "name" 98 | ] 99 | }, 100 | "phone_number": { 101 | "formats": [ 102 | "01#### #####", 103 | "01### ######", 104 | "01#1 ### ####", 105 | "011# ### ####", 106 | "02# #### ####", 107 | "03## ### ####", 108 | "055 #### ####", 109 | "056 #### ####", 110 | "0800 ### ####", 111 | "08## ### ####", 112 | "09## ### ####", 113 | "016977 ####", 114 | "01### #####", 115 | "0500 ######", 116 | "0800 ######" 117 | ] 118 | }, 119 | "cell_phone": { 120 | "formats": [ 121 | "074## ######", 122 | "075## ######", 123 | "076## ######", 124 | "077## ######", 125 | "078## ######", 126 | "079## ######" 127 | ] 128 | } 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/en-TEST.json: -------------------------------------------------------------------------------- 1 | { 2 | "en-TEST": { 3 | "faker": { 4 | "separator": " & ", 5 | "address": { 6 | "city_prefix": ["North"], 7 | "city_suffix": ["town"], 8 | "county": ["Autauga County"], 9 | "country": ["United States of America"], 10 | "country_code": ["US"], 11 | "building_number": ["#####"], 12 | "street_suffix": ["Avenue"], 13 | "secondary_address": ["Apt. ###"], 14 | "postcode": ["#####-####"], 15 | "postcode_by_state": { 16 | "CA": "900##" 17 | }, 18 | "state": ["California"], 19 | "state_abbr": ["CA"], 20 | "time_zone": ["America/Los_Angeles"], 21 | "city": ["#{city_prefix} #{Name.first_name}#{city_suffix}"], 22 | "street_name": ["#{Name.first_name} #{street_suffix}"], 23 | "street_address": ["#{building_number} #{street_name}"], 24 | "default_country": ["United States of America"] 25 | }, 26 | "cat": { 27 | "name": ["Shadow"], 28 | "breed": ["British Semipi-longhair"], 29 | "registry": ["American Cat Fanciers Association"] 30 | }, 31 | "credit_card": { 32 | "visa": ["/4###########L/"], 33 | "mastercard": ["/5[1-5]##-####-####-###L/"], 34 | "discover": ["/6011-####-####-###L/"], 35 | "american_express": ["/34##-######-####L/"], 36 | "diners_club": ["/30[0-5]#-######-###L/"], 37 | "jcb": ["/3528-####-####-###L/"], 38 | "switch": ["/6759-####-####-###L/"], 39 | "solo": ["/6767-####-####-###L/"], 40 | "dankort": "/5019-####-####-###L/", 41 | "maestro": ["/50#{9,16}L/"], 42 | "forbrugsforeningen": "/6007-22##-####-###L/", 43 | "laser": ["/6304###########L/"] 44 | }, 45 | "company": { 46 | "suffix": ["Inc"], 47 | "buzzwords": [ 48 | ["Universal"], 49 | ["24 hour"], 50 | ["software"] 51 | ], 52 | "bs": [ 53 | ["implement"], 54 | ["innovative"], 55 | ["methodologies"] 56 | ], 57 | "name": ["#{Name.last_name} #{suffix}"] 58 | }, 59 | "internet": { 60 | "free_email": ["gmail.com"], 61 | "domain_suffix": ["com"], 62 | "hashtag": ["#art"] 63 | }, 64 | "lorem": { 65 | "words": ["alias"], 66 | "supplemental": ["abbas"] 67 | }, 68 | "name": { 69 | "first_name": ["Vadym"], 70 | "last_name": ["Markov"], 71 | "prefix": ["Mr."], 72 | "suffix": ["I"], 73 | "title": { 74 | "descriptor": ["Lead"], 75 | "level": ["Mobility"], 76 | "job": ["Engineer"] 77 | }, 78 | "name": ["#{prefix} #{first_name} #{last_name}"] 79 | }, 80 | "phone_number": { 81 | "area_code": ["201"], 82 | "exchange_code": ["201"], 83 | "formats": ["###-###-####"] 84 | }, 85 | "cell_phone": { 86 | "formats": ["(###) ###-####"] 87 | }, 88 | "business": { 89 | "credit_card_numbers": ["1234-2121-1221-1211"], 90 | "credit_card_expiry_dates": ["2020-10-12"], 91 | "credit_card_types": ["visa"] 92 | }, 93 | "commerce": { 94 | "color": ["black"], 95 | "department": ["Music", "Video", "Development"], 96 | "product_name": { 97 | "adjective": ["Awesome"], 98 | "material": ["Wooden"], 99 | "product": ["Hat"] 100 | } 101 | }, 102 | "team": { 103 | "creature": ["owls"], 104 | "name": ["#{Address.state} #{creature}"] 105 | }, 106 | "hacker": { 107 | "abbreviation": ["TCP"], 108 | "adjective": ["open-source"], 109 | "noun": ["matrix"], 110 | "verb": ["hack"], 111 | "ingverb": ["bypassing"] 112 | }, 113 | "app": { 114 | "name": ["Namfix"], 115 | "version": ["0.#.#"], 116 | "author": ["#{Name.name}"] 117 | }, 118 | "bank": { 119 | "name": ["ABN AMRO CORPORATE FINANCE LIMITED"], 120 | "swiftBic": ["AAFMGB21"], 121 | "ibanDetails": { 122 | "bankCountryCode": ["EN"], 123 | "ibanLetterCode": ["????"], 124 | "ibanDigits": ["############"] 125 | } 126 | }, 127 | "programming_language": { 128 | "name": ["Elixir"], 129 | "creator": ["José Valim"] 130 | }, 131 | "hobbit": { 132 | "character": ["Bilbo Baggins"], 133 | "thorins_company": ["Thorin Oakenshield"], 134 | "quote": ["Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?"], 135 | "location": ["Bree"] 136 | }, 137 | "vehicle": { 138 | "manufacture": [ 139 | "Volkswagen" 140 | ], 141 | "makes": [ 142 | "BMW" 143 | ], 144 | "models_by_make": { 145 | "BMW": [ 146 | "328i" 147 | ] 148 | }, 149 | "colors": [ 150 | "Red" 151 | ], 152 | "transmissions": [ 153 | "Automanual" 154 | ], 155 | "drive_types": [ 156 | "4x2/2-wheel drive" 157 | ], 158 | "fuel_types": [ 159 | "Compressed Natural Gas" 160 | ], 161 | "styles": [ 162 | "XL" 163 | ], 164 | "car_types": [ 165 | "Cargo Van" 166 | ], 167 | "car_options": [ 168 | "A/C: Front" 169 | ], 170 | "doors": [ 171 | 1 172 | ], 173 | "engine_sizes": [ 174 | 4 175 | ] 176 | }, 177 | "ham": { 178 | "name": ["Smithfield Ham"] 179 | }, 180 | "gender": { 181 | "type": ["Non-binary"], 182 | "binary_type": ["Male"] 183 | }, 184 | "car": { 185 | "brand": ["BMW"] 186 | }, 187 | "zelda": { 188 | "game": ["Ocarina of Time"] 189 | }, 190 | "house": { 191 | "furniture": ["chair"], 192 | "room": ["bedroom"] 193 | } 194 | } 195 | } 196 | } -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "en-US": { 3 | "faker": { 4 | "internet": { 5 | "domain_suffix": [ 6 | "com", 7 | "us", 8 | "biz", 9 | "info", 10 | "name", 11 | "net", 12 | "org" 13 | ] 14 | }, 15 | "address": { 16 | "default_country": [ 17 | "United States", 18 | "United States of America", 19 | "USA" 20 | ], 21 | "postcode_by_state": { 22 | "AL": "350##", 23 | "AK": "995##", 24 | "AS": "967##", 25 | "AZ": "850##", 26 | "AR": "717##", 27 | "CA": "900##", 28 | "CO": "800##", 29 | "CT": "061##", 30 | "DC": "204##", 31 | "DE": "198##", 32 | "FL": "322##", 33 | "GA": "301##", 34 | "HI": "967##", 35 | "ID": "832##", 36 | "IL": "600##", 37 | "IN": "463##", 38 | "IA": "510##", 39 | "KS": "666##", 40 | "KY": "404##", 41 | "LA": "701##", 42 | "ME": "042##", 43 | "MD": "210##", 44 | "MA": "026##", 45 | "MI": "480##", 46 | "MN": "555##", 47 | "MS": "387##", 48 | "MO": "650##", 49 | "MT": "590##", 50 | "NE": "688##", 51 | "NV": "898##", 52 | "NH": "036##", 53 | "NJ": "076##", 54 | "NM": "880##", 55 | "NY": "122##", 56 | "NC": "288##", 57 | "ND": "586##", 58 | "OH": "444##", 59 | "OK": "730##", 60 | "OR": "979##", 61 | "PA": "186##", 62 | "RI": "029##", 63 | "SC": "299##", 64 | "SD": "577##", 65 | "TN": "383##", 66 | "TX": "798##", 67 | "UT": "847##", 68 | "VT": "050##", 69 | "VA": "222##", 70 | "WA": "990##", 71 | "WV": "247##", 72 | "WI": "549##", 73 | "WY": "831##" 74 | } 75 | }, 76 | "phone_number": { 77 | "area_code": [ 78 | "201", 79 | "202", 80 | "203", 81 | "205", 82 | "206", 83 | "207", 84 | "208", 85 | "209", 86 | "210", 87 | "212", 88 | "213", 89 | "214", 90 | "215", 91 | "216", 92 | "217", 93 | "218", 94 | "219", 95 | "224", 96 | "225", 97 | "227", 98 | "228", 99 | "229", 100 | "231", 101 | "234", 102 | "239", 103 | "240", 104 | "248", 105 | "251", 106 | "252", 107 | "253", 108 | "254", 109 | "256", 110 | "260", 111 | "262", 112 | "267", 113 | "269", 114 | "270", 115 | "276", 116 | "281", 117 | "283", 118 | "301", 119 | "302", 120 | "303", 121 | "304", 122 | "305", 123 | "307", 124 | "308", 125 | "309", 126 | "310", 127 | "312", 128 | "313", 129 | "314", 130 | "315", 131 | "316", 132 | "317", 133 | "318", 134 | "319", 135 | "320", 136 | "321", 137 | "323", 138 | "330", 139 | "331", 140 | "334", 141 | "336", 142 | "337", 143 | "339", 144 | "347", 145 | "351", 146 | "352", 147 | "360", 148 | "361", 149 | "386", 150 | "401", 151 | "402", 152 | "404", 153 | "405", 154 | "406", 155 | "407", 156 | "408", 157 | "409", 158 | "410", 159 | "412", 160 | "413", 161 | "414", 162 | "415", 163 | "417", 164 | "419", 165 | "423", 166 | "424", 167 | "425", 168 | "434", 169 | "435", 170 | "440", 171 | "443", 172 | "445", 173 | "464", 174 | "469", 175 | "470", 176 | "475", 177 | "478", 178 | "479", 179 | "480", 180 | "484", 181 | "501", 182 | "502", 183 | "503", 184 | "504", 185 | "505", 186 | "507", 187 | "508", 188 | "509", 189 | "510", 190 | "512", 191 | "513", 192 | "515", 193 | "516", 194 | "517", 195 | "518", 196 | "520", 197 | "530", 198 | "540", 199 | "541", 200 | "551", 201 | "557", 202 | "559", 203 | "561", 204 | "562", 205 | "563", 206 | "564", 207 | "567", 208 | "570", 209 | "571", 210 | "573", 211 | "574", 212 | "580", 213 | "585", 214 | "586", 215 | "601", 216 | "602", 217 | "603", 218 | "605", 219 | "606", 220 | "607", 221 | "608", 222 | "609", 223 | "610", 224 | "612", 225 | "614", 226 | "615", 227 | "616", 228 | "617", 229 | "618", 230 | "619", 231 | "620", 232 | "623", 233 | "626", 234 | "630", 235 | "631", 236 | "636", 237 | "641", 238 | "646", 239 | "650", 240 | "651", 241 | "660", 242 | "661", 243 | "662", 244 | "667", 245 | "678", 246 | "682", 247 | "701", 248 | "702", 249 | "703", 250 | "704", 251 | "706", 252 | "707", 253 | "708", 254 | "712", 255 | "713", 256 | "714", 257 | "715", 258 | "716", 259 | "717", 260 | "718", 261 | "719", 262 | "720", 263 | "724", 264 | "727", 265 | "731", 266 | "732", 267 | "734", 268 | "737", 269 | "740", 270 | "754", 271 | "757", 272 | "760", 273 | "763", 274 | "765", 275 | "770", 276 | "772", 277 | "773", 278 | "774", 279 | "775", 280 | "781", 281 | "785", 282 | "786", 283 | "801", 284 | "802", 285 | "803", 286 | "804", 287 | "805", 288 | "806", 289 | "808", 290 | "810", 291 | "812", 292 | "813", 293 | "814", 294 | "815", 295 | "816", 296 | "817", 297 | "818", 298 | "828", 299 | "830", 300 | "831", 301 | "832", 302 | "835", 303 | "843", 304 | "845", 305 | "847", 306 | "848", 307 | "850", 308 | "856", 309 | "857", 310 | "858", 311 | "859", 312 | "860", 313 | "862", 314 | "863", 315 | "864", 316 | "865", 317 | "870", 318 | "872", 319 | "878", 320 | "901", 321 | "903", 322 | "904", 323 | "906", 324 | "907", 325 | "908", 326 | "909", 327 | "910", 328 | "912", 329 | "913", 330 | "914", 331 | "915", 332 | "916", 333 | "917", 334 | "918", 335 | "919", 336 | "920", 337 | "925", 338 | "928", 339 | "931", 340 | "936", 341 | "937", 342 | "940", 343 | "941", 344 | "947", 345 | "949", 346 | "952", 347 | "954", 348 | "956", 349 | "959", 350 | "970", 351 | "971", 352 | "972", 353 | "973", 354 | "975", 355 | "978", 356 | "979", 357 | "980", 358 | "984", 359 | "985", 360 | "989" 361 | ], 362 | "exchange_code": [ 363 | "201", 364 | "202", 365 | "203", 366 | "205", 367 | "206", 368 | "207", 369 | "208", 370 | "209", 371 | "210", 372 | "212", 373 | "213", 374 | "214", 375 | "215", 376 | "216", 377 | "217", 378 | "218", 379 | "219", 380 | "224", 381 | "225", 382 | "227", 383 | "228", 384 | "229", 385 | "231", 386 | "234", 387 | "239", 388 | "240", 389 | "248", 390 | "251", 391 | "252", 392 | "253", 393 | "254", 394 | "256", 395 | "260", 396 | "262", 397 | "267", 398 | "269", 399 | "270", 400 | "276", 401 | "281", 402 | "283", 403 | "301", 404 | "302", 405 | "303", 406 | "304", 407 | "305", 408 | "307", 409 | "308", 410 | "309", 411 | "310", 412 | "312", 413 | "313", 414 | "314", 415 | "315", 416 | "316", 417 | "317", 418 | "318", 419 | "319", 420 | "320", 421 | "321", 422 | "323", 423 | "330", 424 | "331", 425 | "334", 426 | "336", 427 | "337", 428 | "339", 429 | "347", 430 | "351", 431 | "352", 432 | "360", 433 | "361", 434 | "386", 435 | "401", 436 | "402", 437 | "404", 438 | "405", 439 | "406", 440 | "407", 441 | "408", 442 | "409", 443 | "410", 444 | "412", 445 | "413", 446 | "414", 447 | "415", 448 | "417", 449 | "419", 450 | "423", 451 | "424", 452 | "425", 453 | "434", 454 | "435", 455 | "440", 456 | "443", 457 | "445", 458 | "464", 459 | "469", 460 | "470", 461 | "475", 462 | "478", 463 | "479", 464 | "480", 465 | "484", 466 | "501", 467 | "502", 468 | "503", 469 | "504", 470 | "505", 471 | "507", 472 | "508", 473 | "509", 474 | "510", 475 | "512", 476 | "513", 477 | "515", 478 | "516", 479 | "517", 480 | "518", 481 | "520", 482 | "530", 483 | "540", 484 | "541", 485 | "551", 486 | "557", 487 | "559", 488 | "561", 489 | "562", 490 | "563", 491 | "564", 492 | "567", 493 | "570", 494 | "571", 495 | "573", 496 | "574", 497 | "580", 498 | "585", 499 | "586", 500 | "601", 501 | "602", 502 | "603", 503 | "605", 504 | "606", 505 | "607", 506 | "608", 507 | "609", 508 | "610", 509 | "612", 510 | "614", 511 | "615", 512 | "616", 513 | "617", 514 | "618", 515 | "619", 516 | "620", 517 | "623", 518 | "626", 519 | "630", 520 | "631", 521 | "636", 522 | "641", 523 | "646", 524 | "650", 525 | "651", 526 | "660", 527 | "661", 528 | "662", 529 | "667", 530 | "678", 531 | "682", 532 | "701", 533 | "702", 534 | "703", 535 | "704", 536 | "706", 537 | "707", 538 | "708", 539 | "712", 540 | "713", 541 | "714", 542 | "715", 543 | "716", 544 | "717", 545 | "718", 546 | "719", 547 | "720", 548 | "724", 549 | "727", 550 | "731", 551 | "732", 552 | "734", 553 | "737", 554 | "740", 555 | "754", 556 | "757", 557 | "760", 558 | "763", 559 | "765", 560 | "770", 561 | "772", 562 | "773", 563 | "774", 564 | "775", 565 | "781", 566 | "785", 567 | "786", 568 | "801", 569 | "802", 570 | "803", 571 | "804", 572 | "805", 573 | "806", 574 | "808", 575 | "810", 576 | "812", 577 | "813", 578 | "814", 579 | "815", 580 | "816", 581 | "817", 582 | "818", 583 | "828", 584 | "830", 585 | "831", 586 | "832", 587 | "835", 588 | "843", 589 | "845", 590 | "847", 591 | "848", 592 | "850", 593 | "856", 594 | "857", 595 | "858", 596 | "859", 597 | "860", 598 | "862", 599 | "863", 600 | "864", 601 | "865", 602 | "870", 603 | "872", 604 | "878", 605 | "901", 606 | "903", 607 | "904", 608 | "906", 609 | "907", 610 | "908", 611 | "909", 612 | "910", 613 | "912", 614 | "913", 615 | "914", 616 | "915", 617 | "916", 618 | "917", 619 | "918", 620 | "919", 621 | "920", 622 | "925", 623 | "928", 624 | "931", 625 | "936", 626 | "937", 627 | "940", 628 | "941", 629 | "947", 630 | "949", 631 | "952", 632 | "954", 633 | "956", 634 | "959", 635 | "970", 636 | "971", 637 | "972", 638 | "973", 639 | "975", 640 | "978", 641 | "979", 642 | "980", 643 | "984", 644 | "985", 645 | "989" 646 | ], 647 | "formats": [ 648 | "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}", 649 | "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}", 650 | "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}", 651 | "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number}", 652 | "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}", 653 | "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}", 654 | "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}", 655 | "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number}", 656 | "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 657 | "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 658 | "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 659 | "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 660 | "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 661 | "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 662 | "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 663 | "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 664 | "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 665 | "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 666 | "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}", 667 | "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}" 668 | ] 669 | } 670 | } 671 | } 672 | } 673 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/ja.json: -------------------------------------------------------------------------------- 1 | { 2 | "ja": { 3 | "faker": { 4 | "address": { 5 | "postcode": [ 6 | "###-####" 7 | ], 8 | "state": [ 9 | "北海道", 10 | "青森県", 11 | "岩手県", 12 | "宮城県", 13 | "秋田県", 14 | "山形県", 15 | "福島県", 16 | "茨城県", 17 | "栃木県", 18 | "群馬県", 19 | "埼玉県", 20 | "千葉県", 21 | "東京都", 22 | "神奈川県", 23 | "新潟県", 24 | "富山県", 25 | "石川県", 26 | "福井県", 27 | "山梨県", 28 | "長野県", 29 | "岐阜県", 30 | "静岡県", 31 | "愛知県", 32 | "三重県", 33 | "滋賀県", 34 | "京都府", 35 | "大阪府", 36 | "兵庫県", 37 | "奈良県", 38 | "和歌山県", 39 | "鳥取県", 40 | "島根県", 41 | "岡山県", 42 | "広島県", 43 | "山口県", 44 | "徳島県", 45 | "香川県", 46 | "愛媛県", 47 | "高知県", 48 | "福岡県", 49 | "佐賀県", 50 | "長崎県", 51 | "熊本県", 52 | "大分県", 53 | "宮崎県", 54 | "鹿児島県", 55 | "沖縄県" 56 | ], 57 | "state_abbr": [ 58 | "1", 59 | "2", 60 | "3", 61 | "4", 62 | "5", 63 | "6", 64 | "7", 65 | "8", 66 | "9", 67 | "10", 68 | "11", 69 | "12", 70 | "13", 71 | "14", 72 | "15", 73 | "16", 74 | "17", 75 | "18", 76 | "19", 77 | "20", 78 | "21", 79 | "22", 80 | "23", 81 | "24", 82 | "25", 83 | "26", 84 | "27", 85 | "28", 86 | "29", 87 | "30", 88 | "31", 89 | "32", 90 | "33", 91 | "34", 92 | "35", 93 | "36", 94 | "37", 95 | "38", 96 | "39", 97 | "40", 98 | "41", 99 | "42", 100 | "43", 101 | "44", 102 | "45", 103 | "46", 104 | "47" 105 | ], 106 | "city_prefix": [ 107 | "北", 108 | "東", 109 | "西", 110 | "南", 111 | "新", 112 | "湖", 113 | "港" 114 | ], 115 | "city_suffix": [ 116 | "市", 117 | "区", 118 | "町", 119 | "村" 120 | ], 121 | "city": [ 122 | "#{city_prefix}#{Name.first_name}#{city_suffix}", 123 | "#{Name.first_name}#{city_suffix}", 124 | "#{city_prefix}#{Name.last_name}#{city_suffix}", 125 | "#{Name.last_name}#{city_suffix}" 126 | ], 127 | "street_name": [ 128 | "#{Name.first_name}#{street_suffix}", 129 | "#{Name.last_name}#{street_suffix}" 130 | ] 131 | }, 132 | "phone_number": { 133 | "formats": [ 134 | "0####-#-####", 135 | "0###-##-####", 136 | "0##-###-####", 137 | "0#-####-####" 138 | ] 139 | }, 140 | "cell_phone": { 141 | "formats": [ 142 | "090-####-####", 143 | "080-####-####", 144 | "070-####-####" 145 | ] 146 | }, 147 | "name": { 148 | "last_name": [ 149 | "佐藤", 150 | "鈴木", 151 | "高橋", 152 | "田中", 153 | "渡辺", 154 | "伊藤", 155 | "山本", 156 | "中村", 157 | "小林", 158 | "加藤", 159 | "吉田", 160 | "山田", 161 | "佐々木", 162 | "山口", 163 | "斎藤", 164 | "松本", 165 | "井上", 166 | "木村", 167 | "林", 168 | "清水" 169 | ], 170 | "first_name": [ 171 | "大翔", 172 | "蓮", 173 | "颯太", 174 | "樹", 175 | "大和", 176 | "陽翔", 177 | "陸斗", 178 | "太一", 179 | "海翔", 180 | "蒼空", 181 | "翼", 182 | "陽菜", 183 | "結愛", 184 | "結衣", 185 | "杏", 186 | "莉子", 187 | "美羽", 188 | "結菜", 189 | "心愛", 190 | "愛菜", 191 | "美咲" 192 | ], 193 | "name": [ 194 | "#{last_name} #{first_name}" 195 | ] 196 | }, 197 | "gender": { 198 | "binary_type": [ 199 | "女性", 200 | "男性" 201 | ] 202 | } 203 | } 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/ko.json: -------------------------------------------------------------------------------- 1 | { 2 | "ko": { 3 | "faker": { 4 | "address": { 5 | "postcode": [ 6 | "###-###" 7 | ], 8 | "state": [ 9 | "강원", 10 | "경기", 11 | "경남", 12 | "경북", 13 | "광주", 14 | "대구", 15 | "대전", 16 | "부산", 17 | "서울", 18 | "울산", 19 | "인천", 20 | "전남", 21 | "전북", 22 | "제주", 23 | "충남", 24 | "충북", 25 | "세종" 26 | ], 27 | "state_abbr": [ 28 | "강원", 29 | "경기", 30 | "경남", 31 | "경북", 32 | "광주", 33 | "대구", 34 | "대전", 35 | "부산", 36 | "서울", 37 | "울산", 38 | "인천", 39 | "전남", 40 | "전북", 41 | "제주", 42 | "충남", 43 | "충북", 44 | "세종" 45 | ], 46 | "city_suffix": [ 47 | "구", 48 | "시", 49 | "군" 50 | ], 51 | "city_name": [ 52 | "강릉", 53 | "양양", 54 | "인제", 55 | "광주", 56 | "구리", 57 | "부천", 58 | "밀양", 59 | "통영", 60 | "창원", 61 | "거창", 62 | "고성", 63 | "양산", 64 | "김천", 65 | "구미", 66 | "영주", 67 | "광산", 68 | "남", 69 | "북", 70 | "고창", 71 | "군산", 72 | "남원", 73 | "동작", 74 | "마포", 75 | "송파", 76 | "용산", 77 | "부평", 78 | "강화", 79 | "수성" 80 | ], 81 | "city": [ 82 | "#{city_name}#{city_suffix}" 83 | ], 84 | "street_root": [ 85 | "상계", 86 | "화곡", 87 | "신정", 88 | "목", 89 | "잠실", 90 | "면목", 91 | "주안", 92 | "안양", 93 | "중", 94 | "정왕", 95 | "구로", 96 | "신월", 97 | "연산", 98 | "부평", 99 | "창", 100 | "만수", 101 | "중계", 102 | "검단", 103 | "시흥", 104 | "상도", 105 | "방배", 106 | "장유", 107 | "상", 108 | "광명", 109 | "신길", 110 | "행신", 111 | "대명", 112 | "동탄" 113 | ], 114 | "street_suffix": [ 115 | "읍", 116 | "면", 117 | "동" 118 | ], 119 | "street_name": [ 120 | "#{street_root}#{street_suffix}" 121 | ] 122 | }, 123 | "phone_number": { 124 | "formats": [ 125 | "0#-#####-####", 126 | "0##-###-####", 127 | "0##-####-####" 128 | ] 129 | }, 130 | "company": { 131 | "suffix": [ 132 | "연구소", 133 | "게임즈", 134 | "그룹", 135 | "전자", 136 | "물산", 137 | "코리아" 138 | ], 139 | "prefix": [ 140 | "주식회사", 141 | "한국" 142 | ], 143 | "name": [ 144 | "#{prefix} #{Name.first_name}", 145 | "#{Name.first_name} #{suffix}" 146 | ] 147 | }, 148 | "internet": { 149 | "free_email": [ 150 | "gmail.com", 151 | "yahoo.co.kr", 152 | "hanmail.net", 153 | "naver.com" 154 | ], 155 | "domain_suffix": [ 156 | "co.kr", 157 | "com", 158 | "biz", 159 | "info", 160 | "ne.kr", 161 | "net", 162 | "or.kr", 163 | "org" 164 | ] 165 | }, 166 | "lorem": { 167 | "words": [ 168 | "국가는", 169 | "법률이", 170 | "정하는", 171 | "바에", 172 | "의하여", 173 | "재외국민을", 174 | "보호할", 175 | "의무를", 176 | "진다.", 177 | "모든", 178 | "국민은", 179 | "신체의", 180 | "자유를", 181 | "가진다.", 182 | "국가는", 183 | "전통문화의", 184 | "계승·발전과", 185 | "민족문화의", 186 | "창달에", 187 | "노력하여야", 188 | "한다.", 189 | "통신·방송의", 190 | "시설기준과", 191 | "신문의", 192 | "기능을", 193 | "보장하기", 194 | "위하여", 195 | "필요한", 196 | "사항은", 197 | "법률로", 198 | "정한다.", 199 | "헌법에", 200 | "의하여", 201 | "체결·공포된", 202 | "조약과", 203 | "일반적으로", 204 | "승인된", 205 | "국제법규는", 206 | "국내법과", 207 | "같은", 208 | "효력을", 209 | "가진다.", 210 | "다만,", 211 | "현행범인인", 212 | "경우와", 213 | "장기", 214 | "3년", 215 | "이상의", 216 | "형에", 217 | "해당하는", 218 | "죄를", 219 | "범하고", 220 | "도피", 221 | "또는", 222 | "증거인멸의", 223 | "염려가", 224 | "있을", 225 | "때에는", 226 | "사후에", 227 | "영장을", 228 | "청구할", 229 | "수", 230 | "있다.", 231 | "저작자·발명가·과학기술자와", 232 | "예술가의", 233 | "권리는", 234 | "법률로써", 235 | "보호한다.", 236 | "형사피고인은", 237 | "유죄의", 238 | "판결이", 239 | "확정될", 240 | "때까지는", 241 | "무죄로", 242 | "추정된다.", 243 | "모든", 244 | "국민은", 245 | "행위시의", 246 | "법률에", 247 | "의하여", 248 | "범죄를", 249 | "구성하지", 250 | "아니하는", 251 | "행위로", 252 | "소추되지", 253 | "아니하며,", 254 | "동일한", 255 | "범죄에", 256 | "대하여", 257 | "거듭", 258 | "처벌받지", 259 | "아니한다.", 260 | "국가는", 261 | "평생교육을", 262 | "진흥하여야", 263 | "한다.", 264 | "모든", 265 | "국민은", 266 | "사생활의", 267 | "비밀과", 268 | "자유를", 269 | "침해받지", 270 | "아니한다.", 271 | "의무교육은", 272 | "무상으로", 273 | "한다.", 274 | "저작자·발명가·과학기술자와", 275 | "예술가의", 276 | "권리는", 277 | "법률로써", 278 | "보호한다.", 279 | "국가는", 280 | "모성의", 281 | "보호를", 282 | "위하여", 283 | "노력하여야", 284 | "한다.", 285 | "헌법에", 286 | "의하여", 287 | "체결·공포된", 288 | "조약과", 289 | "일반적으로", 290 | "승인된", 291 | "국제법규는", 292 | "국내법과", 293 | "같은", 294 | "효력을", 295 | "가진다." 296 | ] 297 | }, 298 | "name": { 299 | "last_name": [ 300 | "김", 301 | "이", 302 | "박", 303 | "최", 304 | "정", 305 | "강", 306 | "조", 307 | "윤", 308 | "장", 309 | "임", 310 | "오", 311 | "한", 312 | "신", 313 | "서", 314 | "권", 315 | "황", 316 | "안", 317 | "송", 318 | "류", 319 | "홍" 320 | ], 321 | "first_name": [ 322 | "서연", 323 | "민서", 324 | "서현", 325 | "지우", 326 | "서윤", 327 | "지민", 328 | "수빈", 329 | "하은", 330 | "예은", 331 | "윤서", 332 | "민준", 333 | "지후", 334 | "지훈", 335 | "준서", 336 | "현우", 337 | "예준", 338 | "건우", 339 | "현준", 340 | "민재", 341 | "우진", 342 | "은주" 343 | ], 344 | "name": [ 345 | "#{last_name} #{first_name}" 346 | ] 347 | } 348 | } 349 | } 350 | } 351 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/nb-NO.json: -------------------------------------------------------------------------------- 1 | { 2 | "nb-NO": { 3 | "faker": { 4 | "address": { 5 | "city_root": [ 6 | "Fet", 7 | "Gjes", 8 | "Høy", 9 | "Inn", 10 | "Fager", 11 | "Lille", 12 | "Lo", 13 | "Mal", 14 | "Nord", 15 | "Nær", 16 | "Sand", 17 | "Sme", 18 | "Stav", 19 | "Stor", 20 | "Tand", 21 | "Ut", 22 | "Vest" 23 | ], 24 | "city_suffix": [ 25 | "berg", 26 | "borg", 27 | "by", 28 | "bø", 29 | "dal", 30 | "eid", 31 | "fjell", 32 | "fjord", 33 | "foss", 34 | "grunn", 35 | "hamn", 36 | "havn", 37 | "helle", 38 | "mark", 39 | "nes", 40 | "odden", 41 | "sand", 42 | "sjøen", 43 | "stad", 44 | "strand", 45 | "strøm", 46 | "sund", 47 | "vik", 48 | "vær", 49 | "våg", 50 | "ø", 51 | "øy", 52 | "ås" 53 | ], 54 | "street_prefix": [ 55 | "Øvre", 56 | "Nedre", 57 | "Søndre", 58 | "Gamle", 59 | "Østre", 60 | "Vestre" 61 | ], 62 | "street_root": [ 63 | "Eike", 64 | "Bjørke", 65 | "Gran", 66 | "Vass", 67 | "Furu", 68 | "Litj", 69 | "Lille", 70 | "Høy", 71 | "Fosse", 72 | "Elve", 73 | "Ku", 74 | "Konvall", 75 | "Soldugg", 76 | "Hestemyr", 77 | "Granitt", 78 | "Hegge", 79 | "Rogne", 80 | "Fiol", 81 | "Sol", 82 | "Ting", 83 | "Malm", 84 | "Klokker", 85 | "Preste", 86 | "Dam", 87 | "Geiterygg", 88 | "Bekke", 89 | "Berg", 90 | "Kirke", 91 | "Kors", 92 | "Bru", 93 | "Blåveis", 94 | "Torg", 95 | "Sjø" 96 | ], 97 | "street_suffix": [ 98 | "alléen", 99 | "bakken", 100 | "berget", 101 | "bråten", 102 | "eggen", 103 | "engen", 104 | "ekra", 105 | "faret", 106 | "flata", 107 | "gata", 108 | "gjerdet", 109 | "grenda", 110 | "gropa", 111 | "hagen", 112 | "haugen", 113 | "havna", 114 | "holtet", 115 | "høgda", 116 | "jordet", 117 | "kollen", 118 | "kroken", 119 | "lia", 120 | "lunden", 121 | "lyngen", 122 | "løkka", 123 | "marka", 124 | "moen", 125 | "myra", 126 | "plassen", 127 | "ringen", 128 | "roa", 129 | "røa", 130 | "skogen", 131 | "skrenten", 132 | "spranget", 133 | "stien", 134 | "stranda", 135 | "stubben", 136 | "stykket", 137 | "svingen", 138 | "tjernet", 139 | "toppen", 140 | "tunet", 141 | "vollen", 142 | "vika", 143 | "åsen" 144 | ], 145 | "common_street_suffix": [ 146 | "sgate", 147 | "svei", 148 | "s Gate", 149 | "s Vei", 150 | "gata", 151 | "veien" 152 | ], 153 | "building_number": [ 154 | "#", 155 | "##" 156 | ], 157 | "secondary_address": [ 158 | "Leil. ###", 159 | "Oppgang A", 160 | "Oppgang B" 161 | ], 162 | "postcode": [ 163 | "####", 164 | "####", 165 | "####", 166 | "0###" 167 | ], 168 | "state": [ 169 | "" 170 | ], 171 | "city": [ 172 | "#{city_root}#{city_suffix}" 173 | ], 174 | "street_name": [ 175 | "#{street_root}#{street_suffix}", 176 | "#{street_prefix} #{street_root}#{street_suffix}", 177 | "#{Name.first_name}#{common_street_suffix}", 178 | "#{Name.last_name}#{common_street_suffix}" 179 | ], 180 | "street_address": [ 181 | "#{street_name} #{building_number}" 182 | ], 183 | "default_country": [ 184 | "Norge" 185 | ] 186 | }, 187 | "company": { 188 | "suffix": [ 189 | "Gruppen", 190 | "AS", 191 | "ASA", 192 | "BA", 193 | "RFH", 194 | "og Sønner" 195 | ], 196 | "name": [ 197 | "#{Name.last_name} #{suffix}", 198 | "#{Name.last_name}-#{Name.last_name}", 199 | "#{Name.last_name}, #{Name.last_name} og #{Name.last_name}" 200 | ] 201 | }, 202 | "internet": { 203 | "domain_suffix": [ 204 | "no", 205 | "com", 206 | "net", 207 | "org" 208 | ] 209 | }, 210 | "name": { 211 | "first_name": [ 212 | "Emma", 213 | "Sara", 214 | "Thea", 215 | "Ida", 216 | "Julie", 217 | "Nora", 218 | "Emilie", 219 | "Ingrid", 220 | "Hanna", 221 | "Maria", 222 | "Sofie", 223 | "Anna", 224 | "Malin", 225 | "Amalie", 226 | "Vilde", 227 | "Frida", 228 | "Andrea", 229 | "Tuva", 230 | "Victoria", 231 | "Mia", 232 | "Karoline", 233 | "Mathilde", 234 | "Martine", 235 | "Linnea", 236 | "Marte", 237 | "Hedda", 238 | "Marie", 239 | "Helene", 240 | "Silje", 241 | "Leah", 242 | "Maja", 243 | "Elise", 244 | "Oda", 245 | "Kristine", 246 | "Aurora", 247 | "Kaja", 248 | "Camilla", 249 | "Mari", 250 | "Maren", 251 | "Mina", 252 | "Selma", 253 | "Jenny", 254 | "Celine", 255 | "Eline", 256 | "Sunniva", 257 | "Natalie", 258 | "Tiril", 259 | "Synne", 260 | "Sandra", 261 | "Madeleine", 262 | "Markus", 263 | "Mathias", 264 | "Kristian", 265 | "Jonas", 266 | "Andreas", 267 | "Alexander", 268 | "Martin", 269 | "Sander", 270 | "Daniel", 271 | "Magnus", 272 | "Henrik", 273 | "Tobias", 274 | "Kristoffer", 275 | "Emil", 276 | "Adrian", 277 | "Sebastian", 278 | "Marius", 279 | "Elias", 280 | "Fredrik", 281 | "Thomas", 282 | "Sondre", 283 | "Benjamin", 284 | "Jakob", 285 | "Oliver", 286 | "Lucas", 287 | "Oskar", 288 | "Nikolai", 289 | "Filip", 290 | "Mats", 291 | "William", 292 | "Erik", 293 | "Simen", 294 | "Ole", 295 | "Eirik", 296 | "Isak", 297 | "Kasper", 298 | "Noah", 299 | "Lars", 300 | "Joakim", 301 | "Johannes", 302 | "Håkon", 303 | "Sindre", 304 | "Jørgen", 305 | "Herman", 306 | "Anders", 307 | "Jonathan", 308 | "Even", 309 | "Theodor", 310 | "Mikkel", 311 | "Aksel" 312 | ], 313 | "feminine_name": [ 314 | "Emma", 315 | "Sara", 316 | "Thea", 317 | "Ida", 318 | "Julie", 319 | "Nora", 320 | "Emilie", 321 | "Ingrid", 322 | "Hanna", 323 | "Maria", 324 | "Sofie", 325 | "Anna", 326 | "Malin", 327 | "Amalie", 328 | "Vilde", 329 | "Frida", 330 | "Andrea", 331 | "Tuva", 332 | "Victoria", 333 | "Mia", 334 | "Karoline", 335 | "Mathilde", 336 | "Martine", 337 | "Linnea", 338 | "Marte", 339 | "Hedda", 340 | "Marie", 341 | "Helene", 342 | "Silje", 343 | "Leah", 344 | "Maja", 345 | "Elise", 346 | "Oda", 347 | "Kristine", 348 | "Aurora", 349 | "Kaja", 350 | "Camilla", 351 | "Mari", 352 | "Maren", 353 | "Mina", 354 | "Selma", 355 | "Jenny", 356 | "Celine", 357 | "Eline", 358 | "Sunniva", 359 | "Natalie", 360 | "Tiril", 361 | "Synne", 362 | "Sandra", 363 | "Madeleine" 364 | ], 365 | "masculine_name": [ 366 | "Markus", 367 | "Mathias", 368 | "Kristian", 369 | "Jonas", 370 | "Andreas", 371 | "Alexander", 372 | "Martin", 373 | "Sander", 374 | "Daniel", 375 | "Magnus", 376 | "Henrik", 377 | "Tobias", 378 | "Kristoffer", 379 | "Emil", 380 | "Adrian", 381 | "Sebastian", 382 | "Marius", 383 | "Elias", 384 | "Fredrik", 385 | "Thomas", 386 | "Sondre", 387 | "Benjamin", 388 | "Jakob", 389 | "Oliver", 390 | "Lucas", 391 | "Oskar", 392 | "Nikolai", 393 | "Filip", 394 | "Mats", 395 | "William", 396 | "Erik", 397 | "Simen", 398 | "Ole", 399 | "Eirik", 400 | "Isak", 401 | "Kasper", 402 | "Noah", 403 | "Lars", 404 | "Joakim", 405 | "Johannes", 406 | "Håkon", 407 | "Sindre", 408 | "Jørgen", 409 | "Herman", 410 | "Anders", 411 | "Jonathan", 412 | "Even", 413 | "Theodor", 414 | "Mikkel", 415 | "Aksel" 416 | ], 417 | "last_name": [ 418 | "Johansen", 419 | "Hansen", 420 | "Andersen", 421 | "Kristiansen", 422 | "Larsen", 423 | "Olsen", 424 | "Solberg", 425 | "Andresen", 426 | "Pedersen", 427 | "Nilsen", 428 | "Berg", 429 | "Halvorsen", 430 | "Karlsen", 431 | "Svendsen", 432 | "Jensen", 433 | "Haugen", 434 | "Martinsen", 435 | "Eriksen", 436 | "Sørensen", 437 | "Johnsen", 438 | "Myhrer", 439 | "Johannessen", 440 | "Nielsen", 441 | "Hagen", 442 | "Pettersen", 443 | "Bakke", 444 | "Skuterud", 445 | "Løken", 446 | "Gundersen", 447 | "Strand", 448 | "Jørgensen", 449 | "Kvarme", 450 | "Røed", 451 | "Sæther", 452 | "Stensrud", 453 | "Moe", 454 | "Kristoffersen", 455 | "Jakobsen", 456 | "Holm", 457 | "Aas", 458 | "Lie", 459 | "Moen", 460 | "Andreassen", 461 | "Vedvik", 462 | "Nguyen", 463 | "Jacobsen", 464 | "Torgersen", 465 | "Ruud", 466 | "Krogh", 467 | "Christiansen", 468 | "Bjerke", 469 | "Aalerud", 470 | "Borge", 471 | "Sørlie", 472 | "Berge", 473 | "Østli", 474 | "Ødegård", 475 | "Torp", 476 | "Henriksen", 477 | "Haukelidsæter", 478 | "Fjeld", 479 | "Danielsen", 480 | "Aasen", 481 | "Fredriksen", 482 | "Dahl", 483 | "Berntsen", 484 | "Arnesen", 485 | "Wold", 486 | "Thoresen", 487 | "Solheim", 488 | "Skoglund", 489 | "Bakken", 490 | "Amundsen", 491 | "Solli", 492 | "Smogeli", 493 | "Kristensen", 494 | "Glosli", 495 | "Fossum", 496 | "Evensen", 497 | "Eide", 498 | "Carlsen", 499 | "Østby", 500 | "Vegge", 501 | "Tangen", 502 | "Smedsrud", 503 | "Olstad", 504 | "Lunde", 505 | "Kleven", 506 | "Huseby", 507 | "Bjørnstad", 508 | "Ryan", 509 | "Rasmussen", 510 | "Nygård", 511 | "Nordskaug", 512 | "Nordby", 513 | "Mathisen", 514 | "Hopland", 515 | "Gran", 516 | "Finstad", 517 | "Edvardsen" 518 | ], 519 | "prefix": [ 520 | "Dr.", 521 | "Prof." 522 | ], 523 | "suffix": [ 524 | "Jr.", 525 | "Sr.", 526 | "I", 527 | "II", 528 | "III", 529 | "IV", 530 | "V" 531 | ], 532 | "name": [ 533 | "#{prefix} #{first_name} #{last_name}", 534 | "#{first_name} #{last_name} #{suffix}", 535 | "#{feminine_name} #{feminine_name} #{last_name}", 536 | "#{masculine_name} #{masculine_name} #{last_name}", 537 | "#{first_name} #{last_name} #{last_name}", 538 | "#{first_name} #{last_name}" 539 | ] 540 | }, 541 | "phone_number": { 542 | "formats": [ 543 | "########", 544 | "## ## ## ##", 545 | "### ## ###", 546 | "+47 ## ## ## ##" 547 | ] 548 | } 549 | } 550 | } 551 | } 552 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/nl.json: -------------------------------------------------------------------------------- 1 | { 2 | "nl": { 3 | "faker": { 4 | "address": { 5 | "postcode": "####??" 6 | }, 7 | "bank": { 8 | "name": [ 9 | "UBS CLEARING AND EXECUTION SERVICES LIMITED", 10 | "ABN AMRO CORPORATE FINANCE LIMITED", 11 | "ABN AMRO FUND MANAGERS LIMITED", 12 | "ABN AMRO HOARE GOVETT SECURITIES", 13 | "ABN AMRO HOARE GOVETT CORPORATE FINANCE LTD.", 14 | "ALKEN ASSET MANAGEMENT", 15 | "ABN AMRO HOARE GOVETT LIMITED", 16 | "AAC CAPITAL PARTNERS LIMITED", 17 | "ABBOTSTONE AGRICULTURAL PROPERTY UNIT TRUST", 18 | "ABN AMRO QUOTED INVESTMENTS (UK) LIMITED", 19 | "ABN AMRO MEZZANINE (UK) LIMITED", 20 | "ABBEY LIFE", 21 | "SANTANDER UK PLC", 22 | "OTKRITIE SECURITIES LIMITED", 23 | "ABC INTERNATIONAL BANK PLC", 24 | "ALLIED BANK PHILIPPINES (UK) PLC", 25 | "ABU DHABI ISLAMIC BANK", 26 | "ABG SUNDAL COLLIER LIMITED", 27 | "PGMS (GLASGOW) LIMITED", 28 | "ABINGWORTH MANAGEMENT LIMITED", 29 | "THE ROYAL BANK OF SCOTLAND PLC (FORMER RBS NV)" 30 | ], 31 | "swiftBic": [ 32 | "AACCGB21", 33 | "AACNGB21", 34 | "AAFMGB21", 35 | "AAHOGB21", 36 | "AAHVGB21", 37 | "AANLGB21", 38 | "AANLGB2L", 39 | "AAOGGB21", 40 | "AAPEGB21", 41 | "AAPUGB21", 42 | "AAQIGB21", 43 | "ABAZGB21", 44 | "ABBEGB21", 45 | "ABBYGB2L", 46 | "ABCCGB22", 47 | "ABCEGB2L", 48 | "ABCMGB21", 49 | "ABDIGB21", 50 | "ABECGB21", 51 | "ABFIGB21", 52 | "ABMNGB21", 53 | "ABNAGB21VOC" 54 | ], 55 | "ibanDetails": { 56 | "bankCountryCode": "NL", 57 | "ibanLetterCode": ["RABO", "BUNQ", "ABNA", "INGB"], 58 | "ibanDigits": "############", 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Sources/Fakery/Resources/Locales/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "zh-CN": { 3 | "faker": { 4 | "address": { 5 | "city_prefix": [ 6 | "长", 7 | "上", 8 | "南", 9 | "西", 10 | "北", 11 | "诸", 12 | "宁", 13 | "珠", 14 | "武", 15 | "衡", 16 | "成", 17 | "福", 18 | "厦", 19 | "贵", 20 | "吉", 21 | "海", 22 | "太", 23 | "济", 24 | "安", 25 | "吉", 26 | "包" 27 | ], 28 | "city_suffix": [ 29 | "沙市", 30 | "京市", 31 | "宁市", 32 | "安市", 33 | "乡县", 34 | "海市", 35 | "码市", 36 | "汉市", 37 | "阳市", 38 | "都市", 39 | "州市", 40 | "门市", 41 | "阳市", 42 | "口市", 43 | "原市", 44 | "南市", 45 | "徽市", 46 | "林市", 47 | "头市" 48 | ], 49 | "building_number": [ 50 | "#####", 51 | "####", 52 | "###", 53 | "##", 54 | "#" 55 | ], 56 | "street_suffix": [ 57 | "巷", 58 | "街", 59 | "路", 60 | "桥", 61 | "侬", 62 | "旁", 63 | "中心", 64 | "栋" 65 | ], 66 | "postcode": [ 67 | "######" 68 | ], 69 | "state": [ 70 | "北京市", 71 | "上海市", 72 | "天津市", 73 | "重庆市", 74 | "黑龙江省", 75 | "吉林省", 76 | "辽宁省", 77 | "内蒙古", 78 | "河北省", 79 | "新疆", 80 | "甘肃省", 81 | "青海省", 82 | "陕西省", 83 | "宁夏", 84 | "河南省", 85 | "山东省", 86 | "山西省", 87 | "安徽省", 88 | "湖北省", 89 | "湖南省", 90 | "江苏省", 91 | "四川省", 92 | "贵州省", 93 | "云南省", 94 | "广西省", 95 | "西藏", 96 | "浙江省", 97 | "江西省", 98 | "广东省", 99 | "福建省", 100 | "海南省", 101 | "香港", 102 | "澳门" 103 | ], 104 | "state_abbr": [ 105 | "京", 106 | "沪", 107 | "津", 108 | "渝", 109 | "黑", 110 | "吉", 111 | "辽", 112 | "蒙", 113 | "冀", 114 | "新", 115 | "甘", 116 | "青", 117 | "陕", 118 | "宁", 119 | "豫", 120 | "鲁", 121 | "晋", 122 | "皖", 123 | "鄂", 124 | "湘", 125 | "苏", 126 | "川", 127 | "黔", 128 | "滇", 129 | "桂", 130 | "藏", 131 | "浙", 132 | "赣", 133 | "粤", 134 | "闽", 135 | "琼", 136 | "港", 137 | "澳" 138 | ], 139 | "city": [ 140 | "#{city_prefix}#{city_suffix}" 141 | ], 142 | "street_name": [ 143 | "#{Name.last_name}#{street_suffix}" 144 | ], 145 | "street_address": [ 146 | "#{street_name}#{building_number}号" 147 | ], 148 | "default_country": [ 149 | "中国" 150 | ] 151 | }, 152 | "name": { 153 | "last_name": [ 154 | "王", 155 | "李", 156 | "张", 157 | "刘", 158 | "陈", 159 | "杨", 160 | "黄", 161 | "吴", 162 | "赵", 163 | "周", 164 | "徐", 165 | "孙", 166 | "马", 167 | "朱", 168 | "胡", 169 | "林", 170 | "郭", 171 | "何", 172 | "高", 173 | "罗", 174 | "郑", 175 | "梁", 176 | "谢", 177 | "宋", 178 | "唐", 179 | "许", 180 | "邓", 181 | "冯", 182 | "韩", 183 | "曹", 184 | "曾", 185 | "彭", 186 | "萧", 187 | "蔡", 188 | "潘", 189 | "田", 190 | "董", 191 | "袁", 192 | "于", 193 | "余", 194 | "叶", 195 | "蒋", 196 | "杜", 197 | "苏", 198 | "魏", 199 | "程", 200 | "吕", 201 | "丁", 202 | "沈", 203 | "任", 204 | "姚", 205 | "卢", 206 | "傅", 207 | "钟", 208 | "姜", 209 | "崔", 210 | "谭", 211 | "廖", 212 | "范", 213 | "汪", 214 | "陆", 215 | "金", 216 | "石", 217 | "戴", 218 | "贾", 219 | "韦", 220 | "夏", 221 | "邱", 222 | "方", 223 | "侯", 224 | "邹", 225 | "熊", 226 | "孟", 227 | "秦", 228 | "白", 229 | "江", 230 | "阎", 231 | "薛", 232 | "尹", 233 | "段", 234 | "雷", 235 | "黎", 236 | "史", 237 | "龙", 238 | "陶", 239 | "贺", 240 | "顾", 241 | "毛", 242 | "郝", 243 | "龚", 244 | "邵", 245 | "万", 246 | "钱", 247 | "严", 248 | "赖", 249 | "覃", 250 | "洪", 251 | "武", 252 | "莫", 253 | "孔" 254 | ], 255 | "first_name": [ 256 | "绍齐", 257 | "博文", 258 | "梓晨", 259 | "胤祥", 260 | "瑞霖", 261 | "明哲", 262 | "天翊", 263 | "凯瑞", 264 | "健雄", 265 | "耀杰", 266 | "潇然", 267 | "子涵", 268 | "越彬", 269 | "钰轩", 270 | "智辉", 271 | "致远", 272 | "俊驰", 273 | "雨泽", 274 | "烨磊", 275 | "晟睿", 276 | "文昊", 277 | "修洁", 278 | "黎昕", 279 | "远航", 280 | "旭尧", 281 | "鸿涛", 282 | "伟祺", 283 | "荣轩", 284 | "越泽", 285 | "浩宇", 286 | "瑾瑜", 287 | "皓轩", 288 | "擎苍", 289 | "擎宇", 290 | "志泽", 291 | "子轩", 292 | "睿渊", 293 | "弘文", 294 | "哲瀚", 295 | "雨泽", 296 | "楷瑞", 297 | "建辉", 298 | "晋鹏", 299 | "天磊", 300 | "绍辉", 301 | "泽洋", 302 | "鑫磊", 303 | "鹏煊", 304 | "昊强", 305 | "伟宸", 306 | "博超", 307 | "君浩", 308 | "子骞", 309 | "鹏涛", 310 | "炎彬", 311 | "鹤轩", 312 | "越彬", 313 | "风华", 314 | "靖琪", 315 | "明辉", 316 | "伟诚", 317 | "明轩", 318 | "健柏", 319 | "修杰", 320 | "志泽", 321 | "弘文", 322 | "峻熙", 323 | "嘉懿", 324 | "煜城", 325 | "懿轩", 326 | "烨伟", 327 | "苑博", 328 | "伟泽", 329 | "熠彤", 330 | "鸿煊", 331 | "博涛", 332 | "烨霖", 333 | "烨华", 334 | "煜祺", 335 | "智宸", 336 | "正豪", 337 | "昊然", 338 | "明杰", 339 | "立诚", 340 | "立轩", 341 | "立辉", 342 | "峻熙", 343 | "弘文", 344 | "熠彤", 345 | "鸿煊", 346 | "烨霖", 347 | "哲瀚", 348 | "鑫鹏", 349 | "昊天", 350 | "思聪", 351 | "展鹏", 352 | "笑愚", 353 | "志强", 354 | "炫明", 355 | "雪松", 356 | "思源", 357 | "智渊", 358 | "思淼", 359 | "晓啸", 360 | "天宇", 361 | "浩然", 362 | "文轩", 363 | "鹭洋", 364 | "振家", 365 | "乐驹", 366 | "晓博", 367 | "文博", 368 | "昊焱", 369 | "立果", 370 | "金鑫", 371 | "锦程", 372 | "嘉熙", 373 | "鹏飞", 374 | "子默", 375 | "思远", 376 | "浩轩", 377 | "语堂", 378 | "聪健", 379 | "明", 380 | "文", 381 | "果", 382 | "思", 383 | "鹏", 384 | "驰", 385 | "涛", 386 | "琪", 387 | "浩", 388 | "航", 389 | "彬" 390 | ], 391 | "name": [ 392 | "#{last_name}#{first_name}" 393 | ] 394 | }, 395 | "phone_number": { 396 | "formats": [ 397 | "###-########", 398 | "####-########", 399 | "###########" 400 | ] 401 | } 402 | } 403 | } 404 | } 405 | -------------------------------------------------------------------------------- /Tests/Fakery/ConfigSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class ConfigSpec: QuickSpec { 6 | override func spec() { 7 | describe("Config") { 8 | it("has default values") { 9 | expect(Config.defaultLocale).to(equal("en")) 10 | expect(Config.dirPath).to(equal("Resources/Locales")) 11 | expect(Config.pathExtension).to(equal("json")) 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Tests/Fakery/Data/ParserSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class ParserSpec: QuickSpec { 6 | override func spec() { 7 | describe("Parser") { 8 | var parser: Parser! 9 | 10 | beforeEach { 11 | parser = Parser() 12 | } 13 | 14 | describe("#init") { 15 | it("sets default values") { 16 | expect(parser.locale).to(equal(Config.defaultLocale)) 17 | expect(parser.provider).notTo(beNil()) 18 | } 19 | } 20 | 21 | describe("parsing") { 22 | beforeEach { 23 | parser.locale = "en-TEST" 24 | } 25 | 26 | describe("#fetch") { 27 | context("when the key is correct") { 28 | it("returns the correct text") { 29 | let city = parser.fetch("address.city") 30 | expect(city).to(equal("North Vadymtown")) 31 | 32 | let name = parser.fetch("name.name") 33 | expect(name).to(equal("Mr. Vadym Markov")) 34 | 35 | let team = parser.fetch("team.name") 36 | expect(team).to(equal("California owls")) 37 | } 38 | } 39 | 40 | context("when the key is incorrect") { 41 | it("returns the empty text") { 42 | let dummy = parser.fetch("dummy") 43 | expect(dummy).to(equal("")) 44 | } 45 | } 46 | } 47 | 48 | describe("#fetchRaw") { 49 | context("when the key is correct") { 50 | it("returns the correct text") { 51 | if let city = (parser.fetchRaw("address.city") as? [String])?[0] { 52 | expect(city).to(equal("#{city_prefix} #{Name.first_name}#{city_suffix}")) 53 | } 54 | 55 | if let name = (parser.fetchRaw("name.name") as? [String])?[0] { 56 | expect(name).to(equal("#{prefix} #{first_name} #{last_name}")) 57 | } 58 | 59 | if let team = (parser.fetchRaw("team.name") as? [String])?[0] { 60 | expect(team).to(equal("#{Address.state} #{creature}")) 61 | } 62 | } 63 | } 64 | 65 | context("when the key is incorrect") { 66 | it("returns the empty text") { 67 | if let dummy = parser.fetchRaw("dummy") as? String { 68 | expect(dummy).to(beNil()) 69 | } 70 | } 71 | } 72 | } 73 | 74 | describe("#parse:forSubject") { 75 | context("when the subject is correct") { 76 | it("returns the correct text") { 77 | let text = parser.parse("#{Name.first_name} #{street_suffix} Test", forSubject: "address") 78 | expect(text).to(equal("Vadym Avenue Test")) 79 | } 80 | } 81 | 82 | context("when the subject is incorrect") { 83 | it("returns the passed text") { 84 | let text = parser.parse("test", forSubject: "test") 85 | expect(text).to(equal("test")) 86 | 87 | let text1 = parser.parse("test", forSubject: "address") 88 | expect(text1).to(equal("test")) 89 | } 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Tests/Fakery/Data/ProviderSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class ProviderSpec: QuickSpec { 6 | override func spec() { 7 | describe("Provider") { 8 | var provider: Provider! 9 | 10 | beforeEach { 11 | provider = Provider() 12 | } 13 | 14 | describe("#init") { 15 | it("is initialized") { 16 | expect(provider).notTo(beNil()) 17 | } 18 | 19 | it("has empty translations dictionary") { 20 | expect(provider.translations).notTo(beNil()) 21 | expect(provider.translations.count).to(equal(0)) 22 | } 23 | } 24 | 25 | describe("#dataForLocale") { 26 | it("returns data if locale file exists") { 27 | expect(provider.dataForLocale("en")).notTo(beNil()) 28 | } 29 | 30 | it("returns nil if locale file doesn't exist") { 31 | expect(provider.dataForLocale("bla")).to(beNil()) 32 | } 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Tests/Fakery/FakerSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class FakerSpec: QuickSpec { 6 | override func spec() { 7 | describe("Faker") { 8 | var faker: Faker! 9 | 10 | beforeEach { 11 | faker = Faker() 12 | } 13 | 14 | describe("#init") { 15 | it("sets default values") { 16 | expect(faker.locale).to(equal(Config.defaultLocale)) 17 | expect(faker.parser.locale).to(equal(Config.defaultLocale)) 18 | 19 | expect(faker.address.parser).to(beIdenticalTo(faker.parser)) 20 | expect(faker.app.parser).to(beIdenticalTo(faker.parser)) 21 | expect(faker.zelda.parser).to(beIdenticalTo(faker.parser)) 22 | expect(faker.business.parser).to(beIdenticalTo(faker.parser)) 23 | expect(faker.commerce.parser).to(beIdenticalTo(faker.parser)) 24 | expect(faker.gender.parser).to(beIdenticalTo(faker.parser)) 25 | expect(faker.internet.parser).to(beIdenticalTo(faker.parser)) 26 | expect(faker.lorem.parser).to(beIdenticalTo(faker.parser)) 27 | expect(faker.name.parser).to(beIdenticalTo(faker.parser)) 28 | expect(faker.phoneNumber.parser).to(beIdenticalTo(faker.parser)) 29 | expect(faker.team.parser).to(beIdenticalTo(faker.parser)) 30 | expect(faker.bank.parser).to(beIdenticalTo(faker.parser)) 31 | expect(faker.programmingLanguage.parser).to(beIdenticalTo(faker.parser)) 32 | expect(faker.vehicle.parser).to(beIdenticalTo(faker.parser)) 33 | expect(faker.ham.parser).to(beIdenticalTo(faker.parser)) 34 | expect(faker.house.parser).to(beIdenticalTo(faker.parser)) 35 | } 36 | } 37 | 38 | describe("#address") { 39 | it("should be accessible") { 40 | expect(faker.address).to(beAKindOf(Faker.Address.self)) 41 | } 42 | } 43 | 44 | describe("#app") { 45 | it("should be accessible") { 46 | expect(faker.app).to(beAKindOf(Faker.App.self)) 47 | } 48 | } 49 | 50 | describe("#zelda") { 51 | it("should be accessible") { 52 | expect(faker.zelda).to(beAKindOf(Faker.Zelda.self)) 53 | } 54 | } 55 | 56 | describe("#business") { 57 | it("should be accessible") { 58 | expect(faker.business).to(beAKindOf(Faker.Business.self)) 59 | } 60 | } 61 | 62 | describe("#commerce") { 63 | it("should be accessible") { 64 | expect(faker.commerce).to(beAKindOf(Faker.Commerce.self)) 65 | } 66 | } 67 | 68 | describe("#gender") { 69 | it("should be accessible") { 70 | expect(faker.gender).to(beAKindOf(Faker.Gender.self)) 71 | } 72 | } 73 | 74 | describe("#internet") { 75 | it("should be accessible") { 76 | expect(faker.internet).to(beAKindOf(Faker.Internet.self)) 77 | } 78 | } 79 | 80 | describe("#lorem") { 81 | it("should be accessible") { 82 | expect(faker.lorem).to(beAKindOf(Faker.Lorem.self)) 83 | } 84 | } 85 | 86 | describe("#name") { 87 | it("should be accessible") { 88 | expect(faker.name).to(beAKindOf(Faker.Name.self)) 89 | } 90 | } 91 | 92 | describe("#phoneNumber") { 93 | it("should be accessible") { 94 | expect(faker.phoneNumber).to(beAKindOf(Faker.PhoneNumber.self)) 95 | } 96 | } 97 | 98 | describe("#team") { 99 | it("should be accessible") { 100 | expect(faker.team).to(beAKindOf(Faker.Team.self)) 101 | } 102 | } 103 | 104 | describe("#bank") { 105 | it("should be accessible") { 106 | expect(faker.bank).to(beAKindOf(Faker.Bank.self)) 107 | } 108 | } 109 | 110 | describe("#programmingLanguage") { 111 | it("should be accessible") { 112 | expect(faker.programmingLanguage).to(beAKindOf(Faker.ProgrammingLanguage.self)) 113 | } 114 | } 115 | 116 | describe("#house") { 117 | it("should be accessible") { 118 | expect(faker.house).to(beAKindOf(Faker.House.self)) 119 | } 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/AddressSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class AddressSpec: QuickSpec { 6 | override func spec() { 7 | describe("Address") { 8 | var address: Faker.Address! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | address = Faker.Address(parser: parser) 13 | } 14 | 15 | describe("#city") { 16 | it("returns the correct text") { 17 | let city = address.city() 18 | expect(city).to(equal("North Vadymtown")) 19 | } 20 | } 21 | 22 | describe("#streetName") { 23 | it("returns the correct text") { 24 | let streetName = address.streetName() 25 | expect(streetName).to(equal("Vadym Avenue")) 26 | } 27 | } 28 | 29 | describe("#secondaryAddress") { 30 | it("returns the correct text") { 31 | let secondaryAddress = address.secondaryAddress() 32 | expect(secondaryAddress).to(match("^Apt. \\d{3}$")) 33 | } 34 | } 35 | 36 | describe("#streetAddress") { 37 | context("without secondary") { 38 | it("returns the correct text") { 39 | let streetAddress = address.streetAddress() 40 | expect(streetAddress).to(match("^\\d{5} Vadym Avenue$")) 41 | } 42 | } 43 | 44 | context("include secondary") { 45 | it("returns the correct text") { 46 | let streetAddress = address.streetAddress(includeSecondary: true) 47 | expect(streetAddress).to(match("^\\d{5} Vadym Avenue Apt. \\d{3}$")) 48 | } 49 | } 50 | } 51 | 52 | describe("#buildingNumber") { 53 | it("returns the correct text") { 54 | let buildingNumber = address.buildingNumber() 55 | expect(buildingNumber).to(match("^\\d{5}$")) 56 | } 57 | } 58 | 59 | describe("#postcode") { 60 | context("without the state abbreviation") { 61 | it("returns the correct text") { 62 | let postcode = address.postcode() 63 | expect(postcode).to(match("^\\d{5}-\\d{4}$")) 64 | } 65 | } 66 | 67 | context("with the state abbreviation") { 68 | it("returns the correct text") { 69 | let postcode = address.postcode(stateAbbreviation: "CA") 70 | expect(postcode).to(match("^900\\d{2}$")) 71 | } 72 | } 73 | 74 | context("with the wrong state abbreviation") { 75 | it("returns the correct text") { 76 | let postcode = address.postcode(stateAbbreviation: "TE") 77 | expect(postcode).to(beEmpty()) 78 | } 79 | } 80 | } 81 | 82 | describe("#timeZone") { 83 | it("returns the correct text") { 84 | let timeZone = address.timeZone() 85 | expect(timeZone).to(equal("America/Los_Angeles")) 86 | } 87 | } 88 | 89 | describe("#streetSuffix") { 90 | it("returns the correct text") { 91 | let streetSuffix = address.streetSuffix() 92 | expect(streetSuffix).to(equal("Avenue")) 93 | } 94 | } 95 | 96 | describe("#citySuffix") { 97 | it("returns the correct text") { 98 | let citySuffix = address.citySuffix() 99 | expect(citySuffix).to(equal("town")) 100 | } 101 | } 102 | 103 | describe("#cityPrefix") { 104 | it("returns the correct text") { 105 | let cityPrefix = address.cityPrefix() 106 | expect(cityPrefix).to(equal("North")) 107 | } 108 | } 109 | 110 | describe("#stateAbbreviation") { 111 | it("returns the correct text") { 112 | let stateAbbreviation = address.stateAbbreviation() 113 | expect(stateAbbreviation).to(equal("CA")) 114 | } 115 | } 116 | 117 | describe("#state") { 118 | it("returns the correct text") { 119 | let state = address.state() 120 | expect(state).to(equal("California")) 121 | } 122 | } 123 | 124 | describe("#county") { 125 | it("returns the correct text") { 126 | let country = address.county() 127 | expect(country).to(equal("Autauga County")) 128 | } 129 | } 130 | 131 | describe("#country") { 132 | it("returns the correct text") { 133 | let country = address.country() 134 | expect(country).to(equal("United States of America")) 135 | } 136 | } 137 | 138 | describe("#countryCode") { 139 | it("returns the correct text") { 140 | let countryCode = address.countryCode() 141 | expect(countryCode).to(equal("US")) 142 | } 143 | } 144 | 145 | describe("#latitude") { 146 | it("returns non-zero value") { 147 | let latitude = address.latitude() 148 | expect(latitude).notTo(equal(0)) 149 | } 150 | } 151 | 152 | describe("#longitude") { 153 | it("returns non-zero value") { 154 | let longitude = address.longitude() 155 | expect(longitude).notTo(equal(0)) 156 | } 157 | } 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/AppSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class AppSpec: QuickSpec { 6 | override func spec() { 7 | describe("App") { 8 | var app: Faker.App! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | app = Faker.App(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let name = app.name() 18 | expect(name).to(equal("Namfix")) 19 | } 20 | } 21 | 22 | describe("#version") { 23 | it("returns the correct text") { 24 | let version = app.version() 25 | expect(version).to(match("^0.\\d.\\d$")) 26 | } 27 | } 28 | 29 | describe("#author") { 30 | it("returns the correct text") { 31 | let author = app.author() 32 | expect(author).to(equal("Mr. Vadym Markov")) 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/BankSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class BankSpec: QuickSpec { 6 | override func spec() { 7 | describe("Bank") { 8 | var bank: Faker.Bank! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | bank = Faker.Bank(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let name = bank.name() 18 | expect(name).to(equal("ABN AMRO CORPORATE FINANCE LIMITED")) 19 | } 20 | } 21 | 22 | describe("#swiftBic") { 23 | it("returns a valid BIC") { 24 | let swiftBic = bank.swiftBic() 25 | expect(swiftBic).to(equal("AAFMGB21")) 26 | } 27 | } 28 | 29 | describe("#bban") { 30 | it("returns a valid BBAN") { 31 | let bban = bank.bban() 32 | expect(bban).to(match("[A-Z]{4}\\d{10}")) 33 | } 34 | } 35 | 36 | describe("#iban") { 37 | it("returns a valid IBAN") { 38 | let iban = bank.iban() 39 | expect(iban).to(match("[A-Z]{2}\\d{2}[A-Z]{4}\\d{10}")) 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/BusinessSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class BusinessSpec: QuickSpec { 6 | override func spec() { 7 | describe("Business") { 8 | var business: Faker.Business! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | business = Faker.Business(parser: parser) 13 | } 14 | 15 | describe("#creditCardNumber") { 16 | it("returns the correct text") { 17 | let creditCardNumber = business.creditCardNumber() 18 | expect(creditCardNumber).to(equal("1234-2121-1221-1211")) 19 | } 20 | } 21 | 22 | describe("#creditCardType") { 23 | it("returns the correct text") { 24 | let creditCardType = business.creditCardType() 25 | expect(creditCardType).to(equal("visa")) 26 | } 27 | } 28 | 29 | describe("#creditCardExpiryDate") { 30 | it("returns the correct text") { 31 | let creditCardExpiryDate = business.creditCardExpiryDate() 32 | expect(creditCardExpiryDate).notTo(beNil()) 33 | if let date = creditCardExpiryDate { 34 | let dateString = business.dateFormatter.string(from: date) 35 | expect(dateString).to(equal("2020-10-12")) 36 | } 37 | } 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/CarSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class CarSpec: QuickSpec { 6 | override func spec() { 7 | describe("Car") { 8 | var cars: Faker.Car! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | cars = Faker.Car(parser: parser) 13 | } 14 | 15 | describe("#brand") { 16 | it("returns the correct brand name text") { 17 | let name = cars.brand() 18 | expect(name).to(equal("BMW")) 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/CatSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class CatSpec: QuickSpec { 6 | override func spec() { 7 | describe("Cat") { 8 | var cat: Faker.Cat! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | cat = Faker.Cat(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let name = cat.name() 18 | expect(name).to(equal("Shadow")) 19 | } 20 | } 21 | 22 | describe("#breed") { 23 | it("returns the correct text") { 24 | let breed = cat.breed() 25 | expect(breed).to(equal("British Semipi-longhair")) 26 | } 27 | } 28 | 29 | describe("#registry") { 30 | it("returns the correct text") { 31 | let registry = cat.registry() 32 | expect(registry).to(equal("American Cat Fanciers Association")) 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/CommerceSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class CommerceSpec: QuickSpec { 6 | override func spec() { 7 | describe("Commerce") { 8 | var commerce: Faker.Commerce! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | commerce = Faker.Commerce(parser: parser) 13 | } 14 | 15 | describe("#color") { 16 | it("generates the correct text") { 17 | let color = commerce.color() 18 | expect(color).to(equal("black")) 19 | } 20 | } 21 | 22 | describe("#department") { 23 | it("generates the correct text") { 24 | let department = commerce.department(maximum: 3, fixedAmount: true) 25 | expect(department.range(of: "Music")).notTo(beNil()) 26 | expect(department.range(of: "Video")).notTo(beNil()) 27 | expect(department.range(of: "Development")).notTo(beNil()) 28 | expect(department.range(of: "&")).notTo(beNil()) 29 | expect(department).to(match("^[A-Za-z]+, [A-Za-z]+ & [A-Za-z]+$")) 30 | } 31 | } 32 | 33 | describe("#productName") { 34 | it("generates the correct text") { 35 | let productName = commerce.productName() 36 | expect(productName).to(equal("Awesome Wooden Hat")) 37 | } 38 | } 39 | 40 | describe("#price") { 41 | it("generates the correct number") { 42 | let price = commerce.price() 43 | expect(price > 0.0).to(beTrue()) 44 | expect(price <= 100.0).to(beTrue()) 45 | } 46 | } 47 | 48 | describe("#categories") { 49 | it("returns the correct amount of categories") { 50 | let categories = commerce.categories(3) 51 | expect(categories.count == 3).to(beTrue()) 52 | } 53 | 54 | it("returns the array of unique categories") { 55 | let categories = commerce.categories(3) 56 | var checked: [String] = [] 57 | for category in categories { 58 | if checked.contains(category) { break } 59 | checked.append(category) 60 | } 61 | 62 | expect(checked.count).to(equal(categories.count)) 63 | } 64 | } 65 | 66 | describe("#merge:categories") { 67 | it("returns the correct text") { 68 | let text = commerce.merge(categories: ["One", "Two", "Three", "Four"]) 69 | expect(text).to(equal("One, Two, Three & Four")) 70 | } 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/CompanySpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class CompanySpec: QuickSpec { 6 | override func spec() { 7 | describe("Company") { 8 | var company: Faker.Company! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | company = Faker.Company(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let name = company.name() 18 | expect(name).to(equal("Markov Inc")) 19 | } 20 | } 21 | 22 | describe("#suffix") { 23 | it("returns the correct text") { 24 | let suffix = company.suffix() 25 | expect(suffix).to(equal("Inc")) 26 | } 27 | } 28 | 29 | describe("#catchPhrase") { 30 | it("generates random catch phrase") { 31 | let phrase = company.catchPhrase() 32 | expect(phrase).to(equal("Universal 24 hour software")) 33 | } 34 | } 35 | 36 | describe("#bs") { 37 | it("generates random BS") { 38 | let bs = company.bs() 39 | expect(bs).to(equal("implement innovative methodologies")) 40 | } 41 | } 42 | 43 | describe("#logo") { 44 | it("generates random logo") { 45 | let logo = company.logo() 46 | expect(logo).to(match("^https://pigment.github.io/fake-logos/logos/medium/color/\\d+.png$")) 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/DateSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | import Foundation 4 | @testable import Fakery 5 | 6 | final class DateSpec: QuickSpec { 7 | override func spec() { 8 | describe("Date") { 9 | var date: Faker.Date! 10 | 11 | beforeEach { 12 | date = Faker.Date(parser: Parser()) 13 | } 14 | 15 | describe("#between") { 16 | context("two dates") { 17 | let from = Date(timeIntervalSince1970: 0) 18 | let to = Date(timeIntervalSince1970: 60*60*24*365) 19 | it("returns always a date between those two dates") { 20 | for _ in 1...100 { 21 | let randomDate = date.between(from, to) 22 | expect(randomDate).to(beLessThan(to)) 23 | expect(randomDate).to(beGreaterThan(from)) 24 | } 25 | } 26 | } 27 | } 28 | 29 | describe("#backward") { 30 | context("called with 5 days") { 31 | it("returns a date between today and 5 days before today") { 32 | let daysBefore = 5 33 | let daysBeforeAsSeconds = -Double(daysBefore)*24*60*60 34 | let today = Foundation.Date() 35 | for _ in 1...100 { 36 | let randomDate = date.backward(days: daysBefore) 37 | expect(randomDate).to(beLessThan(today)) 38 | expect(randomDate).to(beGreaterThan(today.addingTimeInterval(daysBeforeAsSeconds))) 39 | } 40 | } 41 | } 42 | } 43 | 44 | describe("#forward") { 45 | context("called with 5 days") { 46 | it("returns a date between today and 5 days after today") { 47 | let daysAfter = 5 48 | let daysAfterAsSeconds = -Double(daysAfter)*24*60*60 49 | let today = Foundation.Date() 50 | for _ in 1...100 { 51 | let randomDate = date.backward(days: daysAfter) 52 | expect(randomDate).to(beLessThan(today)) 53 | expect(randomDate).to(beGreaterThan(today.addingTimeInterval(daysAfterAsSeconds))) 54 | } 55 | } 56 | } 57 | } 58 | 59 | describe("#birthday") { 60 | context("called with ages 30 and 50") { 61 | it("returns a date for a person whose age is between 30 and 50") { 62 | let minAge = 30 63 | let maxAge = 50 64 | 65 | func yearsBeforeDate(_ years: Int, _ date: Foundation.Date) -> Foundation.Date { 66 | var dc = DateComponents() 67 | dc.year = -years 68 | 69 | let calendar = Calendar.current 70 | return calendar.date(byAdding: dc, to: date)! 71 | } 72 | 73 | let today = Foundation.Date() 74 | let minBirthdate = yearsBeforeDate(maxAge, today) 75 | let maxBirthdate = yearsBeforeDate(minAge, today) 76 | for _ in 1...1 { 77 | let randomDate = date.birthday(minAge, maxAge) 78 | expect(randomDate).to(beLessThan(maxBirthdate)) 79 | expect(randomDate).to(beGreaterThan(minBirthdate)) 80 | } 81 | } 82 | } 83 | } 84 | 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/GenderSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class GenderSpec: QuickSpec { 6 | override func spec() { 7 | describe("Gender") { 8 | var gender: Faker.Gender! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | gender = Faker.Gender(parser: parser) 13 | } 14 | 15 | describe("#type") { 16 | it("returns the correct text") { 17 | let type = gender.type() 18 | expect(type).to(equal("Non-binary")) 19 | } 20 | } 21 | 22 | describe("#binary_type") { 23 | it("returns the correct text") { 24 | let binaryType = gender.binaryType() 25 | expect(binaryType).to(equal("Male")) 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/GeneratorSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class GeneratorSpec: QuickSpec { 6 | override func spec() { 7 | describe("Generator") { 8 | var generator: Faker.Generator! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | generator = Faker.Generator(parser: parser) 13 | } 14 | 15 | it("has parser") { 16 | expect(generator.parser).notTo(beNil()) 17 | } 18 | 19 | describe("filling") { 20 | describe("#numerify") { 21 | it("replaces # with random numbers") { 22 | let numerified = generator.numerify("12####") 23 | expect(Int(numerified)).notTo(beNil()) 24 | expect(numerified.contains("#")).to(beFalse()) 25 | expect(numerified).to(match("^12\\d{4}$")) 26 | } 27 | } 28 | 29 | describe("#letterify") { 30 | it("replaces ? with random letters") { 31 | let letterified = generator.letterify("This is awes?me") 32 | expect(letterified.contains("?")).to(beFalse()) 33 | expect(letterified).to(match("^This is awes[A-Za-z]me$")) 34 | } 35 | } 36 | 37 | describe("#bothify") { 38 | it("replaces # with random numbers and ? with random letters") { 39 | let bothified = generator.bothify("#th of ?pril") 40 | expect(bothified.contains("#")).to(beFalse()) 41 | expect(bothified.contains("?")).to(beFalse()) 42 | expect(bothified).to(match("^\\dth of [A-Za-z]pril$")) 43 | } 44 | } 45 | 46 | describe("#alphaNumerify") { 47 | it("removes special characters") { 48 | let latin = generator.alphaNumerify("Øghdasæå!y_=a") 49 | expect(latin).to(equal("ghdasy_a")) 50 | } 51 | } 52 | 53 | describe("#randomWordsFromKey") { 54 | it("generates random words") { 55 | let phrase = generator.randomWordsFromKey("company.buzzwords") 56 | expect(phrase).to(equal("Universal 24 hour software")) 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/HamSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class HamSpec: QuickSpec { 6 | override func spec() { 7 | describe("Ham") { 8 | var ham: Faker.Ham! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | ham = Faker.Ham(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let name = ham.name() 18 | expect(name).to(equal("Smithfield Ham")) 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/HobbitSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class HobbitSpec: QuickSpec { 6 | override func spec() { 7 | describe("Hobbit") { 8 | var hobbit: Faker.Hobbit! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | hobbit = Faker.Hobbit(parser: parser) 13 | } 14 | 15 | describe("#character") { 16 | it("returns the correct text") { 17 | let character = hobbit.character() 18 | expect(character).to(equal("Bilbo Baggins")) 19 | } 20 | } 21 | 22 | describe("#thorins_company") { 23 | it("returns the correct text") { 24 | let thorinsCompany = hobbit.thorinsCompany() 25 | expect(thorinsCompany).to(equal("Thorin Oakenshield")) 26 | } 27 | } 28 | 29 | describe("#quote") { 30 | it("returns the correct text") { 31 | let quote = hobbit.quote() 32 | expect(quote).to(equal("Do you wish me a good morning, or mean that it is a good morning whether I want it or" 33 | + " not; or that you feel good this morning; or that it is a morning to be good on?")) 34 | } 35 | } 36 | 37 | describe("#location") { 38 | it("returns the correct text") { 39 | let location = hobbit.location() 40 | expect(location).to(equal("Bree")) 41 | } 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/HouseSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class HouseSpec: QuickSpec { 6 | override func spec() { 7 | describe("House") { 8 | var house: Faker.House! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | house = Faker.House(parser: parser) 13 | } 14 | 15 | describe("#furniture") { 16 | it("returns the correct text") { 17 | let furniture = house.furniture() 18 | expect(furniture).to(equal("chair")) 19 | } 20 | } 21 | 22 | describe("#room") { 23 | it("returns the correct text") { 24 | let room = house.room() 25 | expect(room).to(equal("bedroom")) 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/InternetSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class InternetSpec: QuickSpec { 6 | override func spec() { 7 | describe("Internet") { 8 | let emailFormat = "[\\w._%+-]+@[\\w.-]+\\.\\w{2,}" 9 | var internet: Faker.Internet! 10 | 11 | beforeEach { 12 | let parser = Parser(locale: "en-TEST") 13 | internet = Faker.Internet(parser: parser) 14 | } 15 | 16 | describe("#username") { 17 | context("without separator - by default") { 18 | it("returns the correct text") { 19 | let username = internet.username() 20 | expect(username).to(match("^[A-Za-z]+(\\d+)?$")) 21 | } 22 | } 23 | 24 | context("with provided separator") { 25 | it("returns the correct text") { 26 | let username = internet.username(separator: "_") 27 | if username.lengthOfBytes(using: String.Encoding.utf8) > 5 { 28 | expect(username.contains("_")).notTo(beNil()) 29 | } else { 30 | expect(username.contains("_")).to(beNil()) 31 | } 32 | } 33 | } 34 | 35 | it("doesn't have the ' symbol in the result") { 36 | let username = internet.username(separator: "'_'") 37 | expect(username.contains("'")).to(beFalse()) 38 | } 39 | } 40 | 41 | describe("#domainName") { 42 | it("returns the correct text") { 43 | let domainName = internet.domainName() 44 | expect(domainName).to(equal("markov.com")) 45 | } 46 | } 47 | 48 | describe("#domainWord") { 49 | it("returns the correct text") { 50 | let domainWord = internet.domainWord() 51 | expect(domainWord).to(equal("markov")) 52 | } 53 | } 54 | 55 | describe("#domainSuffix") { 56 | it("returns the correct text") { 57 | let domainSuffix = internet.domainSuffix() 58 | expect(domainSuffix).to(equal("com")) 59 | } 60 | } 61 | 62 | describe("#email") { 63 | it("returns the correct email address") { 64 | let email = internet.email() 65 | expect(email).to(match(emailFormat)) 66 | } 67 | } 68 | 69 | describe("#freeEmail") { 70 | it("returns the correct email address") { 71 | let freeEmail = internet.freeEmail() 72 | expect(freeEmail).to(match(emailFormat)) 73 | expect(freeEmail).to(match("^[\\w._%+-]+@gmail.com$")) 74 | } 75 | } 76 | 77 | describe("#safeEmail") { 78 | it("returns the correct email address") { 79 | let safeEmail = internet.safeEmail() 80 | expect(safeEmail).to(match(emailFormat)) 81 | expect(safeEmail).to(match("^[\\w._%+-]+@example.(org|com|net)$")) 82 | } 83 | } 84 | 85 | describe("#password") { 86 | context("without min and max - 8...16 by default") { 87 | it("returns the correct password") { 88 | let password = internet.password() 89 | let length = password.lengthOfBytes(using: String.Encoding.utf8) 90 | expect(length >= 8 && length <= 16).to(beTrue()) 91 | } 92 | } 93 | 94 | context("with provided min length and max length") { 95 | it("returns the correct password when min = max") { 96 | let password = internet.password(minimumLength: 3, maximumLength: 3) 97 | let length = password.lengthOfBytes(using: String.Encoding.utf8) 98 | expect(length == 3).to(beTrue()) 99 | } 100 | 101 | it("returns the correct password when min > max") { 102 | let password = internet.password(minimumLength: 3, maximumLength: 4) 103 | let length = password.lengthOfBytes(using: String.Encoding.utf8) 104 | expect(length >= 3 && length <= 4).to(beTrue()) 105 | } 106 | 107 | it("returns the correct password when min < max") { 108 | let password = internet.password(minimumLength: 4, maximumLength: 3) 109 | let length = password.lengthOfBytes(using: String.Encoding.utf8) 110 | expect(length == 4).to(beTrue()) 111 | } 112 | } 113 | } 114 | 115 | describe("#ipV4Address") { 116 | it("returns the correct text") { 117 | let ipV4Address = internet.ipV4Address() 118 | expect(ipV4Address).to(match( 119 | "((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])")) 120 | } 121 | } 122 | 123 | describe("#ipV6Address") { 124 | it("returns the correct text") { 125 | let ipV6Address = internet.ipV6Address() 126 | expect(ipV6Address).to(match( 127 | "^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4})")) 128 | } 129 | } 130 | 131 | describe("#url") { 132 | it("returns the correct URL") { 133 | let url = internet.url() 134 | expect(url).to(match("^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$")) 135 | } 136 | } 137 | 138 | describe("#image") { 139 | it("returns the correct Image URL with default size") { 140 | let url = internet.image() 141 | expect(url).to(equal("https://lorempixel.com/320/200")) 142 | } 143 | 144 | it("returns the correct Image URL with a specified size") { 145 | let url = internet.image(width: 200, height: 150) 146 | expect(url).to(equal("https://lorempixel.com/200/150")) 147 | } 148 | } 149 | 150 | describe("#templateImage") { 151 | it("returns the correct Image URL with defaults") { 152 | let url = internet.templateImage() 153 | expect(url).to(equal("https://dummyimage.com/320x200/000000/ffffff")) 154 | } 155 | 156 | it("returns the correct Image URL with a specified size") { 157 | let url = internet.templateImage(width: 200, height: 150, 158 | backColorHex: "2e4bc2", frontColorHex: "ccdb28") 159 | expect(url).to(equal("https://dummyimage.com/200x150/2e4bc2/ccdb28")) 160 | } 161 | } 162 | 163 | describe("#hashtag") { 164 | it("returns the correct hashtag") { 165 | let hashtag = internet.hashtag() 166 | expect(hashtag).to(equal("#art")) 167 | } 168 | } 169 | } 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/LoremSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class LoremSpec: QuickSpec { 6 | override func spec() { 7 | describe("Lorem") { 8 | var lorem: Faker.Lorem! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | lorem = Faker.Lorem(parser: parser) 13 | } 14 | 15 | describe("#word") { 16 | it("returns the correct text") { 17 | let word = lorem.word() 18 | expect(word).to(match("^[A-Za-z]+$")) 19 | } 20 | } 21 | 22 | describe("#words") { 23 | context("without the amount - 3 words by default") { 24 | it("returns the expected amount of words") { 25 | let word = lorem.words() 26 | expect(word).to(match("^[A-Za-z]+ [A-Za-z]+ [A-Za-z]+$")) 27 | } 28 | } 29 | 30 | context("with the amount of words") { 31 | it("returns the expected amount of words") { 32 | let word = lorem.words(amount: 2) 33 | expect(word).to(match("^[A-Za-z]+ [A-Za-z]+$")) 34 | } 35 | } 36 | } 37 | 38 | describe("#character") { 39 | it("returns the correct character") { 40 | let char = lorem.character() 41 | expect(char).to(match("^[A-Za-z]$")) 42 | } 43 | } 44 | 45 | describe("#characters") { 46 | context("without the amount - 255 chars by default") { 47 | it("returns the expected amount of characters") { 48 | let chars = lorem.characters() 49 | expect(chars).to(match("^[A-Za-z]{255}")) 50 | } 51 | } 52 | 53 | context("with the amount of chars") { 54 | it("returns the expected amount of characters") { 55 | let chars = lorem.characters(amount: 7) 56 | expect(chars).to(match("^[A-Za-z]{7}")) 57 | } 58 | } 59 | } 60 | 61 | describe("#sentence") { 62 | context("without the amount - 4 words by default") { 63 | it("returns the expected amount of words") { 64 | let sentence = lorem.sentence() 65 | expect(sentence).to(match("^[A-Z][A-Za-z]+ [A-Za-z]+ [A-Za-z]+ [A-Za-z]+.$")) 66 | } 67 | } 68 | 69 | context("with the amount of words") { 70 | it("returns the expected amount of words") { 71 | let sentence = lorem.sentence(wordsAmount: 2) 72 | expect(sentence).to(match("^[A-Z][A-Za-z]+ [A-Za-z]+.$")) 73 | } 74 | } 75 | } 76 | 77 | describe("#sentences") { 78 | context("without the amount - 3 sentences by default") { 79 | it("returns the expected amount of sentences") { 80 | let sentences = lorem.sentences() 81 | expect(sentences).to(match("^[A-Za-z ]+. [A-Za-z ]+. [A-Za-z ]+.$")) 82 | } 83 | } 84 | 85 | context("with the amount of sentences") { 86 | it("returns the expected amount of sentences") { 87 | let sentences = lorem.sentences(amount: 2) 88 | expect(sentences).to(match("^[A-Za-z ]+. [A-Za-z ]+.$")) 89 | } 90 | } 91 | } 92 | 93 | describe("#paragraph") { 94 | context("without the amount - 3 sentence by default") { 95 | it("returns the expected amount of sentences") { 96 | let paragraph = lorem.paragraph() 97 | expect(paragraph).to(match("^[A-Za-z ]+. [A-Za-z ]+. [A-Za-z ]+.$")) 98 | } 99 | } 100 | 101 | context("with the amount of words") { 102 | it("returns the expected amount of sentences") { 103 | let sentence = lorem.paragraph(sentencesAmount: 2) 104 | expect(sentence).to(match("^[A-Za-z ]+. [A-Za-z ]+.$")) 105 | } 106 | } 107 | } 108 | 109 | describe("#paragraphs") { 110 | context("without the amount - 3 paragraphs by default") { 111 | it("returns the expected amount of paragraphs") { 112 | let paragraphs = lorem.paragraphs() 113 | expect(paragraphs).to(match("^[A-Za-z .]+\\n[A-Za-z .]+\\n[A-Za-z .]+$")) 114 | } 115 | } 116 | 117 | context("with the amount of paragraphs") { 118 | it("returns the expected amount of paragraphs") { 119 | let paragraphs = lorem.paragraphs(amount: 2) 120 | expect(paragraphs).to(match("^[A-Za-z .]+\\n[A-Za-z .]+$")) 121 | } 122 | } 123 | } 124 | 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/NameSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class NameSpec: QuickSpec { 6 | override func spec() { 7 | describe("Name") { 8 | var name: Faker.Name! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | name = Faker.Name(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let text = name.name() 18 | expect(text).to(equal("Mr. Vadym Markov")) 19 | } 20 | } 21 | 22 | describe("#firstName") { 23 | it("returns the correct text") { 24 | let firstName = name.firstName() 25 | expect(firstName).to(equal("Vadym")) 26 | } 27 | } 28 | 29 | describe("#lastName") { 30 | it("returns the correct text") { 31 | let lastName = name.lastName() 32 | expect(lastName).to(equal("Markov")) 33 | } 34 | } 35 | 36 | describe("#prefix") { 37 | it("returns the correct text") { 38 | let prefix = name.prefix() 39 | expect(prefix).to(equal("Mr.")) 40 | } 41 | } 42 | 43 | describe("#suffix") { 44 | it("returns the correct text") { 45 | let suffix = name.suffix() 46 | expect(suffix).to(equal("I")) 47 | } 48 | } 49 | 50 | describe("#title") { 51 | it("returns the correct text") { 52 | let title = name.title() 53 | expect(title).to(equal("Lead Mobility Engineer")) 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/NumberSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class NumberSpec: QuickSpec { 6 | override func spec() { 7 | describe("Number") { 8 | var number: Faker.Number! 9 | 10 | beforeEach { 11 | number = Faker.Number(parser: Parser()) 12 | } 13 | 14 | it("creates contionusly increasing ids") { 15 | expect(number.increasingUniqueId()).to(equal(1)) 16 | expect(number.increasingUniqueId()).to(equal(2)) 17 | expect(number.increasingUniqueId()).to(equal(3)) 18 | } 19 | 20 | it("creates random Ints") { 21 | expect(number.randomInt()) <= 1000 22 | expect(number.randomInt()) >= 0 23 | 24 | expect(number.randomInt(min: 10)) >= 10 25 | expect(number.randomInt(max: 10)) <= 10 26 | 27 | expect(number.randomInt(min: 5, max: 7)) <= 7 28 | expect(number.randomInt(min: 5, max: 7)) >= 5 29 | 30 | expect(number.randomInt(min: 1000000000000, max: 9999999999999)) >= 1000000000000 31 | expect(number.randomInt(min: 1000000000000, max: 9999999999999)) <= 9999999999999 32 | 33 | expect(number.randomInt(min: Int.min, max: Int.max)) >= Int.min 34 | expect(number.randomInt(min: Int.min, max: Int.max)) <= Int.max 35 | 36 | expect(number.randomInt(min: Int.min, max: 0)) >= Int.min 37 | expect(number.randomInt(min: Int.min, max: 0)) <= 0 38 | 39 | } 40 | 41 | it("creates random Floats") { 42 | expect(number.randomFloat()) <= 1000 43 | expect(number.randomFloat()) >= 0 44 | 45 | expect(number.randomFloat(min: 10)) >= 10 46 | expect(number.randomFloat(max: 10)) <= 10 47 | 48 | expect(number.randomFloat(min: 5, max: 7)) <= 7 49 | expect(number.randomFloat(min: 5, max: 7)) >= 5 50 | } 51 | 52 | #if !os(Linux) 53 | it("creates random CGFloats") { 54 | expect(number.randomCGFloat()) <= 1000 55 | expect(number.randomCGFloat()) >= 0 56 | 57 | expect(number.randomCGFloat(min: 10)) >= 10 58 | expect(number.randomCGFloat(max: 10)) <= 10 59 | 60 | expect(number.randomCGFloat(min: 5, max: 7)) <= 7 61 | expect(number.randomCGFloat(min: 5, max: 7)) >= 5 62 | } 63 | #endif 64 | 65 | it("creates random Doubles") { 66 | expect(number.randomDouble()) <= 1000 67 | expect(number.randomDouble()) >= 0 68 | 69 | expect(number.randomDouble(min: 10)) >= 10 70 | expect(number.randomDouble(max: 10)) <= 10 71 | 72 | expect(number.randomDouble(min: 5, max: 7)) <= 7 73 | expect(number.randomDouble(min: 5, max: 7)) >= 5 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/PhoneNumberSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class PhoneNumberSpec: QuickSpec { 6 | override func spec() { 7 | describe("PhoneNumber") { 8 | var phoneNumber: Faker.PhoneNumber! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | phoneNumber = Faker.PhoneNumber(parser: parser) 13 | } 14 | 15 | describe("#phoneNumber") { 16 | it("generates the correct text") { 17 | let phone = phoneNumber.phoneNumber() 18 | expect(phone).to(match("^\\d{3}-\\d{3}-\\d{4}$")) 19 | } 20 | } 21 | 22 | describe("#cellPhone") { 23 | it("generates the correct text") { 24 | let phone = phoneNumber.cellPhone() 25 | expect(phone).to(match("^\\(\\d{3}\\) \\d{3}-\\d{4}$")) 26 | } 27 | } 28 | 29 | describe("#areaCode") { 30 | it("generates the correct text") { 31 | let areaCode = phoneNumber.areaCode() 32 | expect(areaCode).to(equal("201")) 33 | } 34 | } 35 | 36 | describe("#exchangeCode") { 37 | it("generates the correct text") { 38 | let exchangeCode = phoneNumber.exchangeCode() 39 | expect(exchangeCode).to(equal("201")) 40 | } 41 | } 42 | 43 | describe("#subscriberNumber") { 44 | it("generates the correct number with 4 digits") { 45 | let subscriberNumber = phoneNumber.subscriberNumber() 46 | expect(subscriberNumber).to(match("^\\d{4}$")) 47 | } 48 | } 49 | 50 | describe("#numberExtension") { 51 | it("generates the correct text with specified number of digits") { 52 | let numberExtension = phoneNumber.numberExtension(5) 53 | expect(numberExtension).to(match("^\\d{5}$")) 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/ProgrammingLanguageSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class ProgrammingLanguageSpec: QuickSpec { 6 | override func spec() { 7 | describe("Programming Language") { 8 | var language: Faker.ProgrammingLanguage! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | language = Faker.ProgrammingLanguage(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let name = language.name() 18 | expect(name).to(equal("Elixir")) 19 | } 20 | } 21 | 22 | describe("#creator") { 23 | it("returns the correct text") { 24 | let name = language.creator() 25 | expect(name).to(equal("José Valim")) 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/TeamSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class TeamSpec: QuickSpec { 6 | override func spec() { 7 | describe("Team") { 8 | var team: Faker.Team! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | team = Faker.Team(parser: parser) 13 | } 14 | 15 | describe("#name") { 16 | it("returns the correct text") { 17 | let name = team.name() 18 | expect(name).to(equal("California owls")) 19 | } 20 | } 21 | 22 | describe("#creature") { 23 | it("returns the correct text") { 24 | let creature = team.creature() 25 | expect(creature).to(equal("owls")) 26 | } 27 | } 28 | 29 | describe("#state") { 30 | it("returns the correct text") { 31 | let state = team.state() 32 | expect(state).to(equal("California")) 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/VehicleSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class VehicleSpec: QuickSpec { 6 | override func spec() { 7 | describe("Vehicle") { 8 | var vehicle: Faker.Vehicle! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | vehicle = Faker.Vehicle(parser: parser) 13 | } 14 | 15 | describe("#manufacture") { 16 | it("returns the correct manufacture") { 17 | let manufacture = vehicle.manufacture() 18 | expect(manufacture).to(equal("Volkswagen")) 19 | } 20 | } 21 | 22 | describe("#make") { 23 | it("returns the correct make") { 24 | let make = vehicle.make() 25 | expect(make).to(equal("BMW")) 26 | } 27 | } 28 | 29 | describe("#colors") { 30 | it("returns the correct color") { 31 | let color = vehicle.colors() 32 | expect(color).to(equal("Red")) 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Tests/Fakery/Generators/ZeldaSpec.swift: -------------------------------------------------------------------------------- 1 | import Quick 2 | import Nimble 3 | @testable import Fakery 4 | 5 | final class ZeldaSpec: QuickSpec { 6 | override func spec() { 7 | describe("Zelda") { 8 | var zelda: Faker.Zelda! 9 | 10 | beforeEach { 11 | let parser = Parser(locale: "en-TEST") 12 | zelda = Faker.Zelda(parser: parser) 13 | } 14 | 15 | describe("#game") { 16 | it("returns the correct text") { 17 | let game = zelda.game() 18 | expect(game).to(equal("Ocarina of Time")) 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LinuxMain.swift 3 | // 4 | // 5 | // Created by Gustavo Campos on 3/16/19. 6 | // 7 | 8 | import XCTest 9 | import Quick 10 | 11 | @testable import FakeryTests 12 | 13 | QCKMain([ 14 | ConfigSpec.self, 15 | FakerSpec.self, 16 | ParserSpec.self, 17 | ProviderSpec.self, 18 | AddressSpec.self, 19 | AppSpec.self, 20 | BusinessSpec.self, 21 | CommerceSpec.self, 22 | CompanySpec.self, 23 | GeneratorSpec.self, 24 | InternetSpec.self, 25 | LoremSpec.self, 26 | NameSpec.self, 27 | NumberSpec.self, 28 | PhoneNumberSpec.self, 29 | TeamSpec.self, 30 | BankSpec.self, 31 | DateSpec.self 32 | ]) 33 | --------------------------------------------------------------------------------