<commit_before># Expecta

An Objective-C/Cocoa Matcher Library

## HOW IS IT BETTER?

The main advantage of using Expecta over other matcher frameworks is that you do not have to specify the data types. Also, the syntax of Expecta matchers is much more readable and does not suffer from parenthesitis. If you have used [Jasmine](http://pivotal.github.com/jasmine/) before, you will feel right at home!

OCHamcrest

```objective-c
assertThat(@"foo", is(equalTo(@"foo")));
assertThatUnsignedInteger(foo, isNot(equalToUnsignedInteger(1)));
assertThatBool([bar isBar], is(equalToBool(YES)));
assertThatDouble(baz, is(equalToDouble(3.14159)));
```

vs.

Expecta

```objective-c
expect(@"foo").toEqual(@"foo");
expect(foo).Not.toEqual(1);
expect([bar isBar]).toEqual(YES);
expect(baz).toEqual(3.14159);
```

## STATUS

Still under heavy development, but usable.

## BUILT-IN MATCHERS

>`expect(x).toEqual(y);` compares objects or primitives x and y and passes if they are identical (==) or equivalent (isEqual:).
>
>`expect(x).toBeNil();` passes if x is nil.
>
>`expect(x).toBeTruthy();` passes if x evaluates to true (non-zero).
>
>`expect(x).toBeFalsy();` passes if x evaluates to false (zero).
>
>`expect(x).toBeInstanceOf([Foo class]);` passes if x is an instance of a class Foo.
>
>`expect(x).toBeKindOf([Foo class]);` passes if x is an instance of a class Foo or if x is an instance of any class that inherits from the class Foo.
>
>`expect([Foo class]).toBeSubclassOf([Bar class]);` passes if the class Foo is a subclass of the class Bar or if it is identical to the class Bar.
>

*More matchers are coming soon!*

Every matcher's criteria can be inverted by prepending `.Not`: (It is `.Not` with a capital `N` because `not` is a keyword in C++.)

>`expect(x).Not.toEqual(y);` compares objects or primitives x and y and passes if they are *not* equivalent.

## WRITING NEW MATCHERS

Writing a new matcher is easy with special macros provided by Expecta. Take a look at how `.toBeKindOf()` matcher is defined:
<commit_msg>updated readme with usage instructions.<commit_after># Expecta

An Objective-C/Cocoa Matcher Library

## HOW IS IT BETTER?

The main advantage of using Expecta over other matcher frameworks is that you do not have to specify the data types. Also, the syntax of Expecta matchers is much more readable and does not suffer from parenthesitis. If you have used [Jasmine](http://pivotal.github.com/jasmine/) before, you will feel right at home!

OCHamcrest

```objective-c
assertThat(@"foo", is(equalTo(@"foo")));
assertThatUnsignedInteger(foo, isNot(equalToUnsignedInteger(1)));
assertThatBool([bar isBar], is(equalToBool(YES)));
assertThatDouble(baz, is(equalToDouble(3.14159)));
```

vs.

Expecta

```objective-c
expect(@"foo").toEqual(@"foo");
expect(foo).Not.toEqual(1);
expect([bar isBar]).toEqual(YES);
expect(baz).toEqual(3.14159);
```

## STATUS

Still under heavy development, but usable.

## USAGE

Clone from Github, add `expecta/src` folder to your Xcode project and then add `#import "Expecta.h"` to your test code.
Works best with [Cedar BDD Framework](http://pivotal.github.com/cedar/).

## BUILT-IN MATCHERS

>`expect(x).toEqual(y);` compares objects or primitives x and y and passes if they are identical (==) or equivalent (isEqual:).
>
>`expect(x).toBeNil();` passes if x is nil.
>
>`expect(x).toBeTruthy();` passes if x evaluates to true (non-zero).
>
>`expect(x).toBeFalsy();` passes if x evaluates to false (zero).
>
>`expect(x).toBeInstanceOf([Foo class]);` passes if x is an instance of a class Foo.
>
>`expect(x).toBeKindOf([Foo class]);` passes if x is an instance of a class Foo or if x is an instance of any class that inherits from the class Foo.
>
>`expect([Foo class]).toBeSubclassOf([Bar class]);` passes if the class Foo is a subclass of the class Bar or if it is identical to the class Bar.
>

*More matchers are coming soon!*

Every matcher's criteria can be inverted by prepending `.Not`: (It is `.Not` with a capital `N` because `not` is a keyword in C++.)

>`expect(x).Not.toEqual(y);` compares objects or primitives x and y and passes if they are *not* equivalent.

## WRITING NEW MATCHERS

Writing a new matcher is easy with special macros provided by Expecta. Take a look at how `.toBeKindOf()` matcher is defined:

{'fraction_non_alphanumeric': 0.12821712681328964, 'fraction_numerical': 0.006551240056153486, 'mean_word_length': 5.029619181946403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6282012', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1333, 'n_words': 542}