-
Notifications
You must be signed in to change notification settings - Fork 4
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
Integrate Connectivity + Example Project #16
Closed
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
09dcb8c
Add Connectivity as dep
dgyesbreghs 2a28ede
Make sure we can use `Bundle` to run `CocoaPods`
dgyesbreghs 32909d3
Pod Install
dgyesbreghs 74b80f6
Implement the NetworkReachability class
dgyesbreghs f1eac9e
Pod Install
dgyesbreghs b358d46
Add the isConnected prop
dgyesbreghs fa4d8b5
Update readme
dgyesbreghs 6df67c1
Add Example project to test Reachability
dgyesbreghs 2f7e87b
Add extra logs
dgyesbreghs b4e348a
Small refactor
dgyesbreghs ec55f8f
Add a spec
dgyesbreghs 8f690d1
12: Refactor the NetworkReachability class
dgyesbreghs 66d49de
Connectivity: Add a extension so we can pass the right configurations
dgyesbreghs 77bd2a9
Connectivity: Refactor a little bit
dgyesbreghs 1caf079
Connectivity: Make sure we can pass the right connectivityURLs
dgyesbreghs 52657e2
Connectivity: Modify the mockedConfig
dgyesbreghs 5cdb5cf
Connectivity: Some Xcode stuff
dgyesbreghs 096a5ae
Connectivity: Expose everything through the Service Class
dgyesbreghs 5f0c309
Connectivity: Modify Example Project
dgyesbreghs 451c670
Connectivity: Small spec
dgyesbreghs 5ff374f
Add a extra config file
dgyesbreghs 1a8e2fd
Update README
dgyesbreghs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
43 changes: 43 additions & 0 deletions
43
Example/Tests/Specs/Reachability/NetworkReachabilitySpec.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// NetworkReachabilitySpec.swift | ||
// Tests | ||
// | ||
// Created by Dylan Gyesbreghs on 02/01/2019. | ||
// Copyright © 2019 icapps. All rights reserved. | ||
// | ||
|
||
import Quick | ||
import Nimble | ||
import Mockingjay | ||
import Connectivity | ||
|
||
@testable import Cara | ||
|
||
class NetworkReachabilitySpec: QuickSpec { | ||
|
||
class MockedNetworkReachability: NetworkReachability { | ||
override func startListening() { | ||
guard let listener = listener else { return } | ||
listener(ConnectivityStatus.connectedViaWiFi) | ||
} | ||
} | ||
|
||
override func spec() { | ||
describe("CodableSerializer") { | ||
var networkReachability: NetworkReachability! | ||
beforeEach { | ||
networkReachability = MockedNetworkReachability() | ||
} | ||
|
||
it("should return ConnectivityStatus.connectedViaWiFi.") { | ||
waitUntil { done in | ||
networkReachability.listener = { status in | ||
expect(status) == ConnectivityStatus.connectedViaWiFi | ||
done() | ||
} | ||
networkReachability.startListening() | ||
} | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mostly do when testing external libraries like these. I create a mock object like you did above and I stub all the methods that could potentially be called by Cara.
ex.
Here is what I test:
I would not trigger it on the mocked object though. What I would do in this case I would create a
MockedConnectivity
and test if the correct method is triggered on that class.If it's unclear, I can show you in one of my projects somewhere this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made a couple of changes, but it will be useful if you can show a example next week 🙂