Latest0.2.0
Homepagehttps://github.com/Nonchalant/FactoryProvider
LicenseMIT
Platformsios 8.0, osx 10.9, watchos 2.0, tvos 9.0, requires ARC
FrameworksFoundation
Authors

:factory: FactoryProvider :factory:

Build Status
Version
Platform
GitHub license
GitHub release
Xcode
Swift
Swift Package Manager

Generate boilerplate of factory Swift framework.

Requirements

FactoryProvider works on the following platforms:

  • iOS 8+
  • Mac OSX 10.9+
  • watchOS 2+
  • tvOS 9+

Supports

Struct, Enum

FactoryProvider

1. Installation

CocoaPods

FactoryProvider runtime is available through CocoaPods. To install it, simply add the following line to your test target in your Podfile:

pod "FactoryProvider"

And add the following Run script build phase to your test target’s Build Phases:

"${PODS_ROOT}/FactoryProvider/generate" --config .factory.yml

After running once, locate Factories.generated.swift and drag it into your Xcode test target group.

.factory.yml

includes: # paths of file or directory to generate
  - Input/SubInput1
  - Input/SubInput2/Source.swift
excludes: # paths of file or directory not to generate
  - Input/SubInput1/SubSubInput
  - Input/SubInput2/Source.swift
testables: # testable targets
  - target1
  - target2
output: output/Factories.generated.swift # path of generated file

2. Usage

You can get a instance to call <TypeName>.provide(). Each properties are set to default value.

struct Climber {
    let name: String
    let age: Int
}

let climber = Climber.provide()

3. Lens

<TypeName>.provide() provides fixed instance. You can modify each property by Lens.

Get

let name = Climber.provide().name or Climber._name.get(Climber.provide())
// ""

Set

let climber = Climber.provide() |> Climber._name *~ "Climber"
// Climber(name: "Climber", age: 0)

Modify

let name = Climber.provide() |> Climber._name *~ { "Climber" |> { $0 + $0 } }()
// Climber(name: "ClimberClimber", age: 0)

Compose

struct Climber {
    let id: Id
    let name: String

    struct Id {
        let value: String
    }
}

let climber1 = Climber.provide()
// Climber(id: Id(value: ""), name: "")

let climber2 = climber1 |> Climber._id |> Climber.Id._value *~ "id"
// Climber(id: Id(value: "id"), name: "")

Libraries

License

FactoryProvider is available under the MIT License.

Latest podspec

{
    "name": "FactoryProvider",
    "version": "0.2.0",
    "summary": "FactoryProvider - generate boilerplate of factory Swift framework.",
    "description": "FactoryProvider is a framework to generate boilerplate of factory with an easy to write TestCase.nIt generates factories automatically to enable this functionality.",
    "homepage": "https://github.com/Nonchalant/FactoryProvider",
    "license": "MIT",
    "authors": {
        "Takeshi Ihara": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Nonchalant/FactoryProvider.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source_files": [
        "Source/**/*.swift"
    ],
    "preserve_paths": [
        "Generator/**/*",
        "generate"
    ],
    "prepare_command": "curl -Lo generate https://github.com/Nonchalant/FactoryProvider/releases/download/0.2.0/generatenchmod +x generate",
    "frameworks": "Foundation",
    "requires_arc": true,
    "pod_target_xcconfig": {
        "ENABLE_BITCODE": "NO",
        "SWIFT_REFLECTION_METADATA_LEVEL": "none"
    }
}

Pin It on Pinterest

Share This