Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Borek TheAdamBorek

View GitHub Profile
@TheAdamBorek
TheAdamBorek / pre_push.md
Last active Jun 1, 2016
pre_push git hook which invokes synx script before every push
View pre_push.md

Instalation

To install this hook you have to create a pre_push file inside .git/hooks/ and paste there the script written below. Next you have to set execute permisions with following command:

$ chmod a+x pre_push

Don't forget to change the project name inside the script.

@TheAdamBorek
TheAdamBorek / PostsListViewModel.swift
Last active Aug 21, 2016
Inject an generic struct
View PostsListViewModel.swift
//
// Created by Adam Borek on 17.06.2016.
//
import Foundation
import RxSwift
import RxCocoa
class PostsListViewModel {
typealias Index = Int
View RxActionSheet.swift
private var selectedOption: Observable<ImageSource> {
return Observable.create { [weak self] observer in
guard let `self` = self else {
observer.onCompleted()
return Disposables.create()
}
let actionSheet = self.prepareActionSheet(with: observer)
self.presenter?.present(actionSheet)
return Disposables.create {
View ab_rxactionsheet_tests_2.swift
final class ViewModelTests: XCTestCase {
private var subject: AvatarViewModel!
var imageHavingMock: ImageHavingStub!
override func setUp() {
super.setUp()
rx_disposeBag = DisposeBag()
imageHavingMock = ImageHavingStub()
subject = AvatarViewModel(imageReceiver: imageHavingMock)
}
View ab_rxactionsheet_tests_4.swift
let buttonTap = PublishSubject<Void>()
buttonTap.bindTo(subject.chooseImageButtonPressed)
.disposed(by: rx_disposeBag)
View ab_rxactionsheet_tests_6.swift
buttonTap.onNext(())
XCTAssertEqual(resultImage, imageHavingMock.expectedImage)
View ab_rxactionsheet_tests_7.swift
func test_receiveImage_onButtonClick() {
var resultImage: UIImage!
subject.image.drive(onNext: { image in
resultImage = image
}).disposed(by: rx_disposeBag)
buttonTap.onNext(())
XCTAssertEqual(resultImage, imageHavingMock.expectedImage)
}
View ab_rxactionsheet_tests_5.swift
var resultImage: UIImage!
subject.image.drive(onNext: { image in
resultImage = image
}).disposed(by: rx_disposeBag)
View ab_rxactionsheet_tests_8.swift
func test_receiveImage_onButtonClick_version2() {
let testScheduler = TestScheduler(initialClock: 0)
}
You can’t perform that action at this time.