{"id":15048192,"url":"https://github.com/github/specta","last_synced_at":"2025-10-04T08:32:05.124Z","repository":{"id":4223693,"uuid":"5345838","full_name":"github/specta","owner":"github","description":"A light-weight TDD / BDD framework for Objective-C \u0026 Cocoa","archived":true,"fork":true,"pushed_at":"2014-03-24T20:49:42.000Z","size":1073,"stargazers_count":42,"open_issues_count":0,"forks_count":13,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-09-30T00:23:39.453Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"specta/specta","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.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":"2012-08-08T18:43:16.000Z","updated_at":"2024-07-31T03:22:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/github/specta","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fspecta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fspecta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fspecta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fspecta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/specta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235232861,"owners_count":18957059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-09-24T21:09:01.732Z","updated_at":"2025-10-04T08:32:04.269Z","avatar_url":"https://github.com/github.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Specta\n\nA light-weight TDD / BDD framework for Objective-C \u0026 Cocoa.\n\n### FEATURES\n\n* RSpec-like BDD DSL\n* Super quick and easy to set up\n* Runs on top of OCUnit\n* Excellent Xcode integration\n\n### SCREENSHOT\n\n![Specta Screenshot](http://github.com/petejkim/stuff/raw/master/images/specta-screenshot.png)\n\n### SETUP\n\nUse [CocoaPods](http://github.com/CocoaPods/CocoaPods)\n\n```ruby\ntarget :MyApp do\n  # your app dependencies\nend\n\ntarget :MyAppTests do\n  pod 'Specta',      '~\u003e 0.1.11'\n  # pod 'Expecta',     '~\u003e 0.2.1'   # expecta matchers\n  # pod 'OCHamcrest',  '~\u003e 1.7'     # hamcrest matchers\n  # pod 'OCMock',      '~\u003e 2.0.1'   # OCMock\n  # pod 'LRMocky',     '~\u003e 0.9.1'   # LRMocky\nend\n```\n\nor\n\n1. Clone from Github.\n2. Run `rake` in project root to build.\n3. Add a \"Cocoa/Cocoa Touch Unit Testing Bundle\" target if you don't already have one.\n4. Copy and add all header files in `products` folder to the Test target in your Xcode project.\n5. For **OS X projects**, copy and add `libSpecta-macosx.a` in `products` folder to the Test target in your Xcode project.  \n   For **iOS projects**, copy and add `libSpecta-ios-universal.a` in `products` folder to the Test target in your Xcode project.\n6. Add `-ObjC` and `-all_load` to the \"Other Linker Flags\" build setting for the Spec/Test target in your Xcode project.\n7. Add the following to your test code.\n\n```objective-c\n#import \"Specta.h\"\n```\n\nStandard OCUnit matchers such as `STAssertEqualObjects` and `STAssertNil` work, but you probably want to add a nicer matcher framework - [Expecta](http://github.com/petejkim/expecta/) to your setup. Or if you really prefer, [OCHamcrest](https://github.com/jonreid/OCHamcrest) works fine too. Also, add a mocking framework: [OCMock](http://ocmock.org/).\n\n## WRITING SPECS\n\n```objective-c\n#import \"Specta.h\"\n\nSharedExamplesBegin(MySharedExamples)\n// Global shared examples are shared across all spec files.\n\nsharedExamplesFor(@\"a shared behavior\", ^(NSDictionary *data) {\n  it(@\"should do some stuff\", ^{\n    id obj = [data objectForKey:@\"key\"];\n    // ...\n  });\n});\n\nSharedExamplesEnd\n\nSpecBegin(Thing)\n\ndescribe(@\"Thing\", ^{\n  sharedExamplesFor(@\"another shared behavior\", ^(NSDictionary *data) {\n    // Locally defined shared examples can override global shared examples within its scope.\n  });\n\n  beforeAll(^{\n    // This is run once and only once before all of the examples\n    // in this group and before any beforeEach blocks.\n  });\n\n  beforeEach(^{\n    // This is run before each example.\n  });\n\n  it(@\"should do stuff\", ^{\n    // This is an example block. Place your assertions here.\n  });\n\n  it(@\"should do some stuff asynchronously\", ^AsyncBlock {\n    // Async example blocks need to invoke done() callback.\n    done();\n  });\n  // You'll have to build your project with Clang (Apple LLVM Compiler) in order to use this feature.\n\n  itShouldBehaveLike(@\"a shared behavior\", [NSDictionary dictionaryWithObjectsAndKeys:@\"obj\", @\"key\", nil]);\n\n  itShouldBehaveLike(@\"another shared behavior\", ^{\n    // Use a block that returns a dictionary if you need the context to be evaluated lazily,\n    // e.g. to use an object prepared in a beforeEach block.\n    return [NSDictionary dictionaryWithObjectsAndKeys:@\"obj\", @\"key\", nil];\n  });\n\n  describe(@\"Nested examples\", ^{\n    it(@\"should do even more stuff\", ^{\n      // ...\n    });\n  });\n\n  pending(@\"pending example\");\n\n  pending(@\"another pending example\", ^{\n    // ...\n  });\n\n  afterEach(^{\n    // This is run after each example.\n  });\n\n  afterAll(^{\n    // This is run once and only once after all of the examples\n    // in this group and after any afterEach blocks.\n  });\n});\n\nSpecEnd\n```\n\n* `beforeEach` and `afterEach` are also aliased as `before` and `after` respectively.\n* `describe` is also aliased as `context`.\n* `it` is also aliased as `example` and `specify`.\n* `itShouldBehaveLike` is also aliased as `itBehavesLike`.\n* Use `pending` or prepend `x` to `describe`, `context`, `example`, `it`, and `specify` to mark examples or groups as pending.\n* Use `^AsyncBlock` as shown in the example above to make examples wait for completion. `done()` callback needs to be invoked to let Specta know that your test is complete. The default timeout is 10.0 seconds but this can be changed by calling the function `setAsyncSpecTimeout(NSTimeInterval timeout)`.\n* `(before|after)(Each/All)` also accept `^AsyncBlock`s.\n* Do `#define SPT_CEDAR_SYNTAX` before importing Specta if you prefer to write `SPEC_BEGIN` and `SPEC_END` instead of `SpecBegin` and `SpecEnd`.\n* Prepend `f` to your `describe`, `context`, `example`, `it`, and `specify` to set focus on examples or groups. When specs are focused, all unfocused specs are skipped.\n\n### RUNNING SPECS FROM COMMAND LINE / CI\n\n~~Refer to\n[this blog post](http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html)\non how to run specs from command line or in continuous integration\nservers.~~\n\nCheck out Facebook's [xctool](https://github.com/facebook/xctool).\n\n### CONTRIBUTION GUIDELINES\n\n* Please use only spaces and indent 2 spaces at a time.\n* Please prefix instance variable names with a single underscore (`_`).\n* Please prefix custom classes and functions defined in the global scope with `SPT`.\n\n### CONTRIBUTORS\n\n* Christian Niles [(nerdyc)](https://github.com/nerdyc)\n* Dan Palmer [(danpalmer)](https://github.com/danpalmer)\n* Justin Spahr-Summers [(jspahrsummers)](https://github.com/jspahrsummers)\n* Josh Abernathy [(joshaber)](https://github.com/joshaber)\n* Meiwin Fu [(meiwin)](https://github.com/meiwin)\n* Robert Gilliam [(rhgills)](https://github.com/rhgills)\n* Shawn Morel [(strangemonad)](https://github.com/strangemonad)\n* Tom Brow [(brow)](https://github.com/brow)\n* Tony Arnold [(tonyarnold)](https://github.com/tonyarnold)\n\n## LICENSE\n\nCopyright (c) 2012 Peter Jihoon Kim. This software is licensed under the [MIT License](http://github.com/petejkim/specta/raw/master/LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fspecta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Fspecta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fspecta/lists"}