specta / expecta

A Matcher Framework for Objective-C/Cocoa
MIT License
1.59k stars 158 forks source link

Give more descriptive message on `beInstanceOf` when `Class` is passed in expect. #180

Open manuyavuz opened 8 years ago

manuyavuz commented 8 years ago

While I was converting my XCTAssert macros to expect macros, I wrongly copy/pasted actual value as following:

expect([request class]).to.beAMemberOf([MyRequest class]);

where it should have been:

expect(request).to.beAMemberOf([MyRequest class]);

Is this case, expecta failed with the following message:

expected: an instance of MyRequest, got: an instance of MyRequest

which obviously look weird. Could we improve this? We can check if given value is a class struct with the following conditional:

if ([actual class] == actual) {
  // A class struct
} else {
  // An instance
}

But I'm not sure if making that check only in EXPMatchers+beInstanceOf file enough to handle all cases.

If you feel this change is enough, I can move for a PR.

Thanks

orta commented 8 years ago

Yep - this makes sense, definitely