Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 1.98 KB

CONTRIBUTING.md

File metadata and controls

36 lines (26 loc) · 1.98 KB

If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.

Formatting

To keep code in order, we advice you to use SwiftLint. In repository, we provide configured .swiftlint.yml file, that matches our criteria of clean and "Swifty" code.

Testing

Testing code that uses Apple's CoreBluetooth framework is not an easy way - there are no interfaces for CoreBluetooth classes so it is impossible to mock them.

Our previous approach (before RxBluettothKit 5.0) worked in a way that we created our own protocols and classes that wrapped CoreBluetooth ones. It worked pretty well but we had a lot of problems with maintaining that code. Each code or interface change caused changes in a big number of files and in a result it was much more time consuming.

With RxBluetoothKit 5.0 we have proposed new way of handling it. We are cloning each RxBluetootKit class, changing names with _ prefix and changing CoreBluttoth class references to our mock references. Those files you can find in Tests/Autogenerated directory.

CoreBlueeoth mocks are created with use of Swinject - you can find it's template in Templates/Mock.swifttemplate file. Mocks are generated to Tests/Autogenerated.

In a result we have classes that instead of using CoreBluetooth classes are using our own mock classes, so it is really easy to test them.

Configuration

In order to generate those classes you will need to do 3 things:

  1. brew install sourcekitten
  2. Install sourcery - unforntunately due to issue you will need to download binaries and add them to your system's path
  3. brew install gnu-sed

After it, test your configuration with:

scripts/generate-testable.sh

and

scripts/generate-mocks.sh

and check if it succeeded.

If you will have any problems with it just contact one of our maintainers.