Version 0.9.7
Backwards Incompatibility
Deprecations
These are minor changes -- just renames. The deprecated imports and classes still exist for backwards compatibility, but are marked as deprecated.
- The
SpecHelper
class has been renamed toCDRSpecHelper
, an alias has been made, but you should rename to the new prefix styled class name. <Cedar.h>
and<Cedar-iOS.h>
are now the recommended imports to use instead of<SpecHelper.h>
in your PCH file
Major Changes
stub_method
Changes
stub_method is now more type-leinient than before. This allows stubbing of methods that return CLLocationCoordinate2D, for example, to work correctly.
stub_method now supports and_do_block()
, which directly accepts arguments the stubbed method would take. This provides a nicer interface instead of using and_do()
, which got more complicated to use under ARC. Here's an example usage for and_do_block()
:
// defined on the class being faked
- (int)incrementNumber:(int)num {}
fake stub_method(@selector(incrementNumber:)).and_do_block(^int(int num) {
return num + 1;
});
stub_method is also now can better discern when arguments are specified with wildcards specified via Arguments::any([Class class])
and Arguments::anything()
.
And no more type-casting to and_return()
for nil
, you can now do it directly:
fake stub_method(@selector(value)).and_return(nil);
contain
Matcher Changes
First, the contain matcher now supports views:
view should contain(childView);
With the new nested()
method, you can check for arbitrary nesting:
view should contain(grandChildView).nested();
This works for arrays and sets too.
A new assistant sub matcher, an_instance_of()
, can be used to check if an item belongs to a given class:
view should contain(an_instance_of([MyView class]));
It can be used in conjunction with the other new features.
Dictionaries also have specializations for verifying keys and values:
dictionary should contain(@"aKey").as_a_key();
dictionary should contain(@"aValue").as_a_value();
Expectations around nil
Various fixes have been made around how matchers and stubs deal with nil. An example of existing behavior in Cedar:
id value = nil;
id otherValue = nil;
value should equal(otherValue); // fails
This expectation fails in order avoid the common pitfall of objective-c's nil
absorbing method calls to avoid incorrectly passing tests. If you explicitly want nil
, you must use the be_nil
matcher.
Using stub_method().with()
no longer delegates to equal
matcher behavior, because of the nil
behavior explained above. This means implicit nils in with()
work.
Various other nil
behaviors have been fixed:
- using a stubbed method
with(<NSNumber>)
parameter no longer crashes when givennil
. equal
no longer crashes when comparing NSNumbers, but one of the values is nil.- stringifiers correctly handle for
nil
values of other types (e.g. - NSNumber). be_nil
now works against blocks.
Other Changes
File Templates
- File templates use new icons
- File templates now use Xcode-pills for subject-under-test
- The default stringifier no longer crashes when attempting to stringify unsupported c-structs.
- Fixed warnings in project file for users that add cedar as a subproject or newly creates projects via template
Fixed Crashes
- Fixed crashes when running in Mountain Lion
- Fixed crashes for Xcode Plugin with Xcode 5.1
Rakefiles
- xcrun is used in rakefiles instead of hard-coded values when possible
- improved error messaging for
rake upgrade
- cedar will only clean its own templates and not delete its directory
- kill the simulator when after running tests to clear environment variables
- fixed rake install failure when Xcode plugin directory does not exist.
Misc
- Cedar now supports/compiles with 64-bit support
- Xcode Plugin specifies support for Xcode 5.1
- Refactored bootstrapping of test runners (and now have a consistent set of default runners for test bundles)
- podspec file now explicitly links to libc++
- describe and context blocks are released eagerly instead of after the entire spec suite finishes.
- Fixed memory leaks (spies included)