pivotal/cedar — Issue #30: Matcher template semantic issue
Author: jeffremer
Created: 2012-02-07 17:20:29+00:00
State: open

This may be a case of user error, however after setting up cedar in our iOS project and blank test projects from scratch half a dozen times I'm still here scratching my head as to why I can't get any of the matchers to work with object literals. I sent a message to the Google Group a couple weeks ago but noticed it hadn't been approved.

The issue is that if I pass in object literals like `@strings` or `'[NSNumber numberWithInt:2]` to the `equal` or `expect` macros then the examples won't build. The errors usually look like this:

````
Semantic Issue
error: no matching function for call to 'equal' [3]
````

For example, here's a sample spec I set up in a blank project + cedar:

````objective-c
#import

using namespace Cedar::Matchers;

SPEC_BEGIN(ExampleSpec)
describe(@"Example", ^{
it(@"should compare scalars", ^{
expect(1+1).to(equal(2));
});

it(@"should compare objects", ^{
// Works fine
NSString* aString = @"something";
expect(aString).to(equal(aString));

// Works fine
NSString* bString = @"something";
expect(aString).to(equal(bString));

// Semantic Issue
// error: no matching function for call to 'equal' [3]
expect(aString).to(equal(@"something"));

// Semantic Issue
// error: no matching function for call to 'equal' [3]
NSNumber *two = [NSNumber numberWithInt:(1+1)];
expect([NSNumber numberWithInt:(1+1)]).to(equal([NSNumber numberWithInt:(2)]));
});
});
SPEC_END
````

I've detailed the exact setup instructions I've taken along with code and screenshots in this gist: https://gist.github.com/1691576

I've tried to get the target settings to match the Cedar iPhoneSpecs target settings, but still no joy. Any ideas?