Skip to content

Commit 90cf851

Browse files
author
Chris Myers
committed
Merge branch 'master' into answers
2 parents 2d5a7cd + 838a1ad commit 90cf851

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

src/main/scala/com/rea/typesafety/OptionExercises.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ object OptionalExercises1 {
1818
}
1919

2020
object OptionalExercises2 {
21-
def main(args: Array[String]) {
22-
println("Environment for host1 is " + getEnvForHost("host1") + " expecting 'prod'")
23-
println("Environment for host2 is " + getEnvForHost("host2") + " expecting 'test'")
24-
println("Environment for host3 is " + getEnvForHost("host3") + " expecting 'couldn't resolve'")
25-
println("Environment for host4 is " + getEnvForHost("host4") + " expecting 'couldn't resolve'")
26-
27-
println("Should be connected to rea.com: " + connectToReaHostsOnly("host1"))
28-
println("Should be connected to test.rea.com: " + connectToReaHostsOnly("host2"))
29-
println("Should not be connected to netflix.com: " + connectToReaHostsOnly("host3"))
30-
println("Should not be connected to unknown host: " + connectToReaHostsOnly("host4"))
31-
}
3221

3322
val hosts = Map("host1" -> "rea.com", "host2" -> "test.rea.com", "host3" -> "netflix.com")
3423
val envs = Map("rea.com" -> "prod", "test.rea.com" -> "test", "amazon.com" -> "stage")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.rea.typesafety
2+
3+
import org.specs2.mutable.Specification
4+
5+
class OptionalExercises1Spec extends Specification {
6+
7+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.rea.typesafety
2+
3+
import org.specs2.mutable.Specification
4+
import OptionalExercises2._
5+
6+
class OptionalExercises2Spec extends Specification {
7+
"Get Environment for Host" should {
8+
"be prod for host1" in {
9+
getEnvForHost("host1") === "prod"
10+
}
11+
"be test for host2" in {
12+
getEnvForHost("host2") === "test"
13+
}
14+
15+
"be couldn't resolve for host3 and host 4" in {
16+
getEnvForHost("host3") === "couldn't resolve"
17+
getEnvForHost("host4") === "couldn't resolve"
18+
}
19+
20+
}
21+
22+
"Connect to ReaHostsOnly" should {
23+
"connected to rea.com for host1" in {
24+
connectToReaHostsOnly("host1") === "connected to rea.com"
25+
}
26+
"connected to test.rea.com for host2" in {
27+
connectToReaHostsOnly("host2") === "connected to test.rea.com"
28+
}
29+
30+
"not be connected to netflix.com for host3" in {
31+
connectToReaHostsOnly("host3") === "not connected to netflix.com"
32+
}
33+
34+
"not be connected to unknown for host4" in {
35+
connectToReaHostsOnly("host4") === "not connected to unknown host"
36+
}
37+
}
38+
39+
}

0 commit comments

Comments
 (0)