This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Staging: Configuration { | |
var certificate = "ios_distribution" | |
var provisioningProfile = "Brewer_Staging" | |
var buildConfiguration = "Staging" | |
var appIdentifier = "works.sth.brewer.staging" | |
var exportMethod = "ad-hoc" | |
} | |
struct Production: Configuration { | |
var certificate = "ios_distribution" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Configuration { | |
/// file name of the certificate | |
var certificate: String { get } | |
/// file name of the provisioning profile | |
var provisioningProfile: String { get } | |
/// configuration name in xcode project | |
var buildConfiguration: String { get } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func package(config: Configuration) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fastfile: LaneFile { | |
func developerReleaseLane() { | |
desc("Create a developer release") | |
package(config: Staging()) | |
crashlytics | |
} | |
func qaReleaseLane() { | |
desc("Create a qa release") | |
package(config: Production()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func setUp() { | |
super.setUp() | |
mockAPIService = MockApiService() | |
sut = PhotoListViewModel(apiService: mockAPIService) | |
} | |
override func tearDown() { | |
sut = nil | |
mockAPIService = nil | |
super.tearDown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_user_press_for_sale_item() { | |
let indexPath = IndexPath(row: 0, section: 0) | |
//Given some photo stubs | |
mockAPIService.completePhotos = StubGenerator().stubPhotos() | |
sut.initFetch() // Fetch stubs | |
mockAPIService.fetchSuccess() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MockApiService: APIServiceProtocol { | |
var completePhotos: [Photo] = [Photo]() // Array of stubs | |
var completeClosure: ((Bool, [Photo], APIError?) -> ()) | |
func fetchPopularPhoto(complete: @escaping (Bool, [Photo], APIError?) -> ()) { | |
\\...\\ | |
completeClosure = complete | |
} | |
func fetchSuccess() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_user_press_for_sale_item() { | |
//Given a sut with fetched photos | |
let indexPath = IndexPath(row: 0, section: 0) | |
//When | |
sut.userPressed( at: indexPath ) | |
//Assert | |
XCTAssertTrue( sut.isAllowSegue ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MockAPIService: APIServiceProtocol { | |
var completeClosure: ((Bool, [Photo], APIError?) -> ())! | |
func fetchPopularPhoto(complete: @escaping (Bool, [Photo], APIError?) -> ()) { | |
isFetchPopularPhotoCalled = true | |
completeClosure = complete | |
} | |
func fetchSuccess() { | |
completeClosure( true, [Photo](), nil ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func initFetch() { | |
self.isLoading = true | |
apiService.fetchPopularPhoto { [weak self] (success, photos, error) in | |
self?.isLoading = false | |
if let error = error { | |
self?.alertMessage = error.rawValue | |
} else { | |
self?.processFetchedPhoto(photos: photos) | |
} | |
} |