Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssignableToTypeOf returns false without error if exactly one of actual or expected is nil. #281

Merged
merged 2 commits into from
May 11, 2018

Conversation

nwmahoney
Copy link
Contributor

Fixes #280.

cc @rowanjacobs

if exactly one of actual or expected is nil.

Fixes onsi#280.

Signed-off-by: Rowan Jacobs <rojacobs@pivotal.io>
@blgm
Copy link
Collaborator

blgm commented May 11, 2018

With this change:

Expect(nil).To(BeAssignableToTypeOf(nil)) // Error
Expect(17).To(BeAssignableToTypeOf(nil))  // OK
Expect(nil).To(BeAssignableToTypeOf(17))  // OK

I think it should be:

Expect(nil).To(BeAssignableToTypeOf(nil)) // Error
Expect(17).To(BeAssignableToTypeOf(nil))  // Error
Expect(nil).To(BeAssignableToTypeOf(17))  // OK

The matcher should be able to cope with whatever ends up in the Expect(). For other situations you should either:

  • check that it's assignable to a non-nil type, OR
  • check that is nil using the BeNil() matcher

Any thoughts?

Signed-off-by: Rowan Jacobs <rojacobs@pivotal.io>
@rowanjacobs
Copy link

Done!

@blgm blgm merged commit 9c1fb20 into onsi:master May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants