devxoul / RxExpect

RxSwift testing framework
MIT License
104 stars 30 forks source link

Add feature to call assert(...).(not)equal with sequences. #3

Closed DriesSchulten closed 7 years ago

DriesSchulten commented 7 years ago

Sequences (arrays etc) don't conform to the Equatable protocol and therefore couldn't be used in an assert call. For example take a ViewModel that produces lists of objects to hook up to a TableView. The only option was to check .is(Not)Empty and not assert the contents of the sequences to make sure the ViewModel behaves correctly.

This feature add support for Sequences to contain elements that are Equatable. The code is almost similar to the existing code but because of different generic constraint I didn't see a way to reuse/generify more. Improvements/comments on this are welcome.

Also a limitation exists on comparing the result to an empty array; Swift doesn't know the type of the elements of the array so the code doesn't compile. You need to explicitly specify type of the elements of the empty array; see test-case.

devxoul commented 7 years ago

Cool! Thank you for your work :100: This PR has been shipped with 0.4.0 release :tada: