Skip to content

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

@manuyavuz

Description

@manuyavuz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions