Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit e2c8932

Browse files
committed
Custom matchers for examples' tests
1 parent 882f1a3 commit e2c8932

File tree

1 file changed

+45
-104
lines changed

1 file changed

+45
-104
lines changed
Lines changed: 45 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,58 @@
11
package io.continuum.bokeh
22
package examples
33

4+
import scala.util.{Try,Success,Failure}
5+
46
import org.specs2.mutable._
5-
import org.specs2.matcher.TerminationMatchers
7+
import org.specs2.matcher.{Matcher,Expectable}
68

7-
class ExamplesSpec extends Specification with TerminationMatchers {
9+
class ExamplesSpec extends Specification with RunMatchers {
810
sequential
911

10-
val argv = Array[String]("--quiet", "--dev")
12+
val run = new Run("--quiet", "--dev")
1113

1214
"examples.models" should {
13-
"run Anscombe" in {
14-
models.Anscombe.main(argv) must not(throwA[Throwable])
15-
}
16-
17-
"run Calendars" in {
18-
models.Calendars.main(argv) must not(throwA[Throwable])
19-
}
20-
21-
"run Choropleth" in {
22-
models.Choropleth.main(argv) must not(throwA[Throwable])
23-
}
24-
25-
"run ColorSpec" in {
26-
models.ColorSpec.main(argv) must not(throwA[Throwable])
27-
}
28-
29-
"run Colors" in {
30-
models.Colors.main(argv) must not(throwA[Throwable])
31-
}
32-
33-
"run DataTables" in {
34-
models.DataTables.main(argv) must not(throwA[Throwable])
35-
}
36-
37-
"run DateAxis" in {
38-
models.DateAxis.main(argv) must not(throwA[Throwable])
39-
}
40-
41-
"run Daylight" in {
42-
models.Daylight.main(argv) must not(throwA[Throwable])
43-
}
44-
45-
"run Donut" in {
46-
models.Donut.main(argv) must not(throwA[Throwable])
47-
}
48-
49-
"run Gauges" in {
50-
models.Gauges.main(argv) must not(throwA[Throwable])
51-
}
52-
53-
"run Gears" in {
54-
models.Gears.main(argv) must not(throwA[Throwable])
55-
}
56-
57-
"run Glyph1" in {
58-
models.Glyph1.main(argv) must not(throwA[Throwable])
59-
}
60-
61-
"run Glyph2" in {
62-
models.Glyph2.main(argv) must not(throwA[Throwable])
63-
}
64-
65-
"run Grid" in {
66-
models.Grid.main(argv) must not(throwA[Throwable])
67-
}
68-
69-
"run Hover" in {
70-
models.Hover.main(argv) must not(throwA[Throwable])
71-
}
72-
73-
"run Image" in {
74-
models.Image.main(argv) must not(throwA[Throwable])
75-
}
76-
77-
"run ImageURL" in {
78-
models.ImageURL.main(argv) must not(throwA[Throwable])
79-
}
80-
81-
"run Iris" in {
82-
models.Iris.main(argv) must not(throwA[Throwable])
83-
}
84-
85-
"run IrisSplom" in {
86-
models.IrisSplom.main(argv) must not(throwA[Throwable])
87-
}
88-
89-
"run Line" in {
90-
models.Line.main(argv) must not(throwA[Throwable])
91-
}
92-
93-
"run Maps" in {
94-
models.Maps.main(argv) must not(throwA[Throwable])
95-
}
96-
97-
"run MapsCities" in {
98-
models.MapsCities.main(argv) must not(throwA[Throwable])
99-
}
100-
101-
"run Prim" in {
102-
models.Prim.main(argv) must not(throwA[Throwable])
103-
}
104-
105-
"run Sprint" in {
106-
models.Sprint.main(argv) must not(throwA[Throwable])
107-
}
108-
109-
"run Trail" in {
110-
models.Trail.main(argv) must not(throwA[Throwable])
111-
}
15+
"run Anscombe" in { models.Anscombe must run }
16+
"run Calendars" in { models.Calendars must run }
17+
"run Choropleth" in { models.Choropleth must run }
18+
"run ColorSpec" in { models.ColorSpec must run }
19+
"run Colors" in { models.Colors must run }
20+
"run DataTables" in { models.DataTables must run }
21+
"run DateAxis" in { models.DateAxis must run }
22+
"run Daylight" in { models.Daylight must run }
23+
"run Donut" in { models.Donut must run }
24+
"run Gauges" in { models.Gauges must run }
25+
"run Gears" in { models.Gears must run }
26+
"run Glyph1" in { models.Glyph1 must run }
27+
"run Glyph2" in { models.Glyph2 must run }
28+
"run Grid" in { models.Grid must run }
29+
"run Hover" in { models.Hover must run }
30+
"run Image" in { models.Image must run }
31+
"run ImageURL" in { models.ImageURL must run }
32+
"run Iris" in { models.Iris must run }
33+
"run IrisSplom" in { models.IrisSplom must run }
34+
"run Line" in { models.Line must run }
35+
"run Maps" in { models.Maps must run }
36+
"run MapsCities" in { models.MapsCities must run }
37+
"run Prim" in { models.Prim must run }
38+
"run Sprint" in { models.Sprint must run }
39+
"run Trail" in { models.Trail must run }
40+
"run TwinAxis" in { models.TwinAxis must run }
41+
}
42+
}
11243

113-
"run TwinAxis" in {
114-
models.TwinAxis.main(argv) must not(throwA[Throwable])
44+
trait RunMatchers {
45+
class Run(argv: String*) extends Matcher[App] {
46+
def apply[T <: App](app: Expectable[T]) = {
47+
val ret = Try(app.value.main(argv.toArray))
48+
val msg = ret match {
49+
case Success(_) => ""
50+
case Failure(exc) => exc.toString
51+
}
52+
result(ret.isSuccess,
53+
s"${app.description} did run",
54+
s"${app.description} failed to run and failed with $msg",
55+
app)
11556
}
11657
}
11758
}

0 commit comments

Comments
 (0)