Skip to content

Commit c6a6a75

Browse files
committed
[RouteHash] Expose RouteHash Initialize & Add Specs
1 parent 0e88531 commit c6a6a75

3 files changed

Lines changed: 62 additions & 1 deletion

File tree

ReSwiftRouter.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
254B3BAD1D3AD6DD00B1E4F0 /* RouteHashSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 254B3BAC1D3AD6DD00B1E4F0 /* RouteHashSpec.swift */; };
11+
254B3BAE1D3AD6DD00B1E4F0 /* RouteHashSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 254B3BAC1D3AD6DD00B1E4F0 /* RouteHashSpec.swift */; };
12+
254B3BAF1D3AD6DD00B1E4F0 /* RouteHashSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 254B3BAC1D3AD6DD00B1E4F0 /* RouteHashSpec.swift */; };
1013
25C0A9CD1C50AF6400139FA7 /* NavigationActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25C0A9C61C50AF6400139FA7 /* NavigationActions.swift */; };
1114
25C0A9CE1C50AF6400139FA7 /* NavigationReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25C0A9C71C50AF6400139FA7 /* NavigationReducer.swift */; };
1215
25C0A9CF1C50AF6400139FA7 /* NavigationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25C0A9C81C50AF6400139FA7 /* NavigationState.swift */; };
@@ -244,6 +247,7 @@
244247
/* End PBXCopyFilesBuildPhase section */
245248

246249
/* Begin PBXFileReference section */
250+
254B3BAC1D3AD6DD00B1E4F0 /* RouteHashSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RouteHashSpec.swift; path = ReSwiftRouterTests/RouteHashSpec.swift; sourceTree = SOURCE_ROOT; };
247251
25C0A9C51C50AF6400139FA7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ReSwiftRouter/Info.plist; sourceTree = SOURCE_ROOT; };
248252
25C0A9C61C50AF6400139FA7 /* NavigationActions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavigationActions.swift; path = ReSwiftRouter/NavigationActions.swift; sourceTree = SOURCE_ROOT; };
249253
25C0A9C71C50AF6400139FA7 /* NavigationReducer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavigationReducer.swift; path = ReSwiftRouter/NavigationReducer.swift; sourceTree = SOURCE_ROOT; };
@@ -385,6 +389,7 @@
385389
25C0A9D31C50AF8B00139FA7 /* Info.plist */,
386390
25C0A9D41C50AF8B00139FA7 /* ReSwiftRouterIntegrationTests.swift */,
387391
25C0A9D51C50AF8B00139FA7 /* ReSwiftRouterTestsUnitTests.swift */,
392+
254B3BAC1D3AD6DD00B1E4F0 /* RouteHashSpec.swift */,
388393
625E67001C2001F60027C288 /* Frameworks */,
389394
);
390395
name = ReSwiftRouterTests;
@@ -917,6 +922,7 @@
917922
isa = PBXSourcesBuildPhase;
918923
buildActionMask = 2147483647;
919924
files = (
925+
254B3BAE1D3AD6DD00B1E4F0 /* RouteHashSpec.swift in Sources */,
920926
6209C07E1C542838004E6B66 /* ReSwiftRouterIntegrationTests.swift in Sources */,
921927
6209C07F1C54283A004E6B66 /* ReSwiftRouterTestsUnitTests.swift in Sources */,
922928
);
@@ -938,6 +944,7 @@
938944
isa = PBXSourcesBuildPhase;
939945
buildActionMask = 2147483647;
940946
files = (
947+
254B3BAF1D3AD6DD00B1E4F0 /* RouteHashSpec.swift in Sources */,
941948
6209C0AC1C542BCA004E6B66 /* ReSwiftRouterIntegrationTests.swift in Sources */,
942949
6209C0AB1C542BC7004E6B66 /* ReSwiftRouterTestsUnitTests.swift in Sources */,
943950
);
@@ -959,6 +966,7 @@
959966
isa = PBXSourcesBuildPhase;
960967
buildActionMask = 2147483647;
961968
files = (
969+
254B3BAD1D3AD6DD00B1E4F0 /* RouteHashSpec.swift in Sources */,
962970
25C0A9D91C50AF8D00139FA7 /* ReSwiftRouterIntegrationTests.swift in Sources */,
963971
25C0A9DA1C50AF8F00139FA7 /* ReSwiftRouterTestsUnitTests.swift in Sources */,
964972
);

ReSwiftRouter/NavigationState.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import ReSwift
1111
public typealias RouteElementIdentifier = String
1212
public typealias Route = [RouteElementIdentifier]
1313

14+
/// A `Hashable` and `Equatable` presentation of a route.
15+
/// Can be used to check two routes for equality.
1416
public struct RouteHash: Hashable {
1517
let routeHash: String
1618

17-
init(route: Route) {
19+
public init(route: Route) {
1820
self.routeHash = route.joinWithSeparator("/")
1921
}
2022

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// RouteHashTests.swift
3+
// ReSwiftRouter
4+
//
5+
// Created by Benji Encz on 7/16/16.
6+
// Copyright © 2016 Benjamin Encz. All rights reserved.
7+
//
8+
9+
import ReSwiftRouter
10+
import Quick
11+
import Nimble
12+
13+
class RouteHashTests: QuickSpec {
14+
15+
override func spec() {
16+
17+
describe("when two route hashs are initialized with the same elements") {
18+
19+
var routeHash1: RouteHash!
20+
var routeHash2: RouteHash!
21+
22+
beforeEach {
23+
routeHash1 = RouteHash(route: ["part1", "part2"])
24+
routeHash2 = RouteHash(route: ["part1", "part2"])
25+
}
26+
27+
it("both hashs are considered equal") {
28+
expect(routeHash1).to(equal(routeHash2))
29+
}
30+
31+
}
32+
33+
describe("when two route hashs are initialized with different elements") {
34+
35+
var routeHash1: RouteHash!
36+
var routeHash2: RouteHash!
37+
38+
beforeEach {
39+
routeHash1 = RouteHash(route: ["part1", "part2"])
40+
routeHash2 = RouteHash(route: ["part3", "part4"])
41+
}
42+
43+
it("both hashs are considered equal") {
44+
expect(routeHash1).toNot(equal(routeHash2))
45+
}
46+
47+
}
48+
49+
}
50+
51+
}

0 commit comments

Comments
 (0)