{"id":17026256,"url":"https://github.com/kevboh/ktbfactorygirl","last_synced_at":"2026-04-29T19:04:38.532Z","repository":{"id":15425519,"uuid":"18157934","full_name":"kevboh/KTBFactoryGirl","owner":"kevboh","description":"A test resource generator for Objective-C inspired by ruby's factory_girl.","archived":false,"fork":false,"pushed_at":"2014-03-27T00:18:28.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T02:42:38.025Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevboh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-26T23:33:42.000Z","updated_at":"2014-03-27T00:18:29.000Z","dependencies_parsed_at":"2022-08-26T04:12:05.060Z","dependency_job_id":null,"html_url":"https://github.com/kevboh/KTBFactoryGirl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kevboh/KTBFactoryGirl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevboh%2FKTBFactoryGirl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevboh%2FKTBFactoryGirl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevboh%2FKTBFactoryGirl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevboh%2FKTBFactoryGirl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevboh","download_url":"https://codeload.github.com/kevboh/KTBFactoryGirl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevboh%2FKTBFactoryGirl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32439343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T18:12:22.909Z","status":"ssl_error","status_checked_at":"2026-04-29T18:11:33.322Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T07:31:21.652Z","updated_at":"2026-04-29T19:04:38.517Z","avatar_url":"https://github.com/kevboh.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KTBFactoryGirl\n\n[![Version](http://cocoapod-badges.herokuapp.com/v/KTBFactoryGirl/badge.png)](http://cocoadocs.org/docsets/KTBFactoryGirl)\n[![Platform](http://cocoapod-badges.herokuapp.com/p/KTBFactoryGirl/badge.png)](http://cocoadocs.org/docsets/KTBFactoryGirl)\n\nKTBFactoryGirl is an attempt to get something like [ruby's factory_girl](https://github.com/thoughtbot/factory_girl) on iOS (and OS X, once I test it). I don't like bundling gigantic JSON blobs in my test bundles, nor do I like manually setting properties on 20 managed objects when I test Core Data entities. KTBFactoryGirl allows you to predefine factories which act as object templates that can be rapidly built out into NSObject subclasses, NSManagedObjects (or subclasses thereof) that have been inserted into contexts, or JSON blobs. So you can write this:\n\n    // Define a factory for a server's representation of a news feed item.\n    [KTBFactoryGirl define:@\"ServerFeedItem\" as:^(KTBFactoryGirl *feedItem) {\n        // This factory generates a feed item with an incrementing ID.\n        feedItem[@\"id\"]             = [KTBFactoryGirlSequence sequenceFrom:1];\n        // The feed item will be by user 123\n        feedItem[@\"user_id\"]        = @123;\n        // With some scintillating text\n        feedItem[@\"text\"]           = @\"This is my super interesting feed item text!\";\n        // A lot of comments\n        feedItem[@\"comments_count\"] = @50;\n        // A few likes\n        feedItem[@\"likes_count\"]    = @12;\n        // A permalink\n        feedItem[@\"url\"]            = [[KTBFactoryGirlSequence sequenceFrom:1] withBlock:^id(NSInteger currentIndex) {\n            return [NSString stringWithFormat:@\"http://feeds-r-us.com/i/%d\", currentIndex];\n        }];\n        // And a boolean not-deleted flag\n        feedItem[@\"deleted\"]        = @NO;\n    }];\n\n    // Okay, let's define a feed that will contain feed items.\n    [KTBFactoryGirl define:@\"ServerFeed\" as:^(KTBFactoryGirl *feed) {\n        // Set some metadata.\n        feed[@\"timestamp\"]          = @([[NSDate date] timeIntervalSince1970]);\n        feed[@\"user_id\"]            = @123;\n        \n        // Give the feed 3 feed items. Feed items have a special \"ordinal\" property determined by order in the feed.\n        [feed set:@\"feed_items\" withFactory:@\"ServerFeedItem\" count:3 setter:^(KTBFactoryGirl *feedItem, NSInteger itemIndex) {\n            feedItem[@\"ordinal\"]    = @(itemIndex);\n        }];\n    }];\n\nand then do this:\n\n    NSString *json = [KTBFactoryGirl JSONFor:@\"ServerFeed\" options:0 error:NULL];\n\nto get this:\n\n    {\n      \"user_id\": 123,\n      \"feed_items\": [\n        {\n          \"deleted\": false,\n          \"user_id\": 123,\n          \"text\": \"This is my super interesting feed item text!\",\n          \"id\": 1,\n          \"likes_count\": 12,\n          \"comments_count\": 50,\n          \"ordinal\": 0,\n          \"url\": \"http://feeds-r-us.com/i/1\"\n        },\n        {\n          \"deleted\": false,\n          \"user_id\": 123,\n          \"text\": \"This is my super interesting feed item text!\",\n          \"id\": 2,\n          \"likes_count\": 12,\n          \"comments_count\": 50,\n          \"ordinal\": 1,\n          \"url\": \"http://feeds-r-us.com/i/2\"\n        },\n        {\n          \"deleted\": false,\n          \"user_id\": 123,\n          \"text\": \"This is my super interesting feed item text!\",\n          \"id\": 3,\n          \"likes_count\": 12,\n          \"comments_count\": 50,\n          \"ordinal\": 2,\n          \"url\": \"http://feeds-r-us.com/i/3\"\n        }\n      ],\n      \"timestamp\": 1395878480.441685\n    }\n\nI plan on adding examples to show how you can generate NSObject subclasses (using the `build` set of methods) and NSManagedObject insertions (using the `insert` set of methods). Along with, you know, docs and stuff. And tests.\n\n## Note!\n\nThough I'm using this for a few projects, this code is very much in alpha. There's no documentation and definitely bugs. I still think it's pretty neat, though.\n\n## Usage\n\nTo run the example project, clone the repo and run `pod install` from the Example directory. Then check out KTBFactoryGirlExampleTests.m.\n\n## Requirements\n\n## Installation\n\nI plan on submitting to [CocoaPods](http://cocoapods.org) soon. Until I do, you can add this as a pod directly:\n\n    pod \"KTBFactoryGirl\", :git =\u003e 'https://github.com/kevboh/KTBFactoryGirl.git'\n\n## Author\n\nKevin Barrett, kevin@littlespindle.com\n\n## License\n\nKTBFactoryGirl is available under the MIT license. See the LICENSE file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevboh%2Fktbfactorygirl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevboh%2Fktbfactorygirl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevboh%2Fktbfactorygirl/lists"}