Commit afc17a41ccea49c72099bda8eb3cc049d38c01a9

Authored by Andrew Kane
1 parent dcda9666

DRY test

Showing 2 changed files with 15 additions and 12 deletions   Show diff stats
test/geo_shape_test.rb
@@ -28,7 +28,7 @@ class GeoShapeTest < Minitest::Test @@ -28,7 +28,7 @@ class GeoShapeTest < Minitest::Test
28 coordinates: [[[10, 20], [15, 25], [20, 20], [20, 10], [10, 10], [10, 20]]] 28 coordinates: [[[10, 20], [15, 25], [20, 20], [20, 10], [10, 10], [10, 20]]]
29 } 29 }
30 } 30 }
31 - ], Region 31 + ]
32 end 32 end
33 33
34 def test_circle 34 def test_circle
@@ -45,7 +45,7 @@ class GeoShapeTest < Minitest::Test @@ -45,7 +45,7 @@ class GeoShapeTest < Minitest::Test
45 } 45 }
46 } 46 }
47 } 47 }
48 - }, Region 48 + }
49 end 49 end
50 50
51 def test_envelope 51 def test_envelope
@@ -58,7 +58,7 @@ class GeoShapeTest < Minitest::Test @@ -58,7 +58,7 @@ class GeoShapeTest < Minitest::Test
58 } 58 }
59 } 59 }
60 } 60 }
61 - }, Region 61 + }
62 end 62 end
63 63
64 def test_polygon 64 def test_polygon
@@ -71,7 +71,7 @@ class GeoShapeTest < Minitest::Test @@ -71,7 +71,7 @@ class GeoShapeTest < Minitest::Test
71 } 71 }
72 } 72 }
73 } 73 }
74 - }, Region 74 + }
75 end 75 end
76 76
77 def test_multipolygon 77 def test_multipolygon
@@ -87,7 +87,7 @@ class GeoShapeTest < Minitest::Test @@ -87,7 +87,7 @@ class GeoShapeTest < Minitest::Test
87 } 87 }
88 } 88 }
89 } 89 }
90 - }, Region 90 + }
91 end 91 end
92 92
93 def test_disjoint 93 def test_disjoint
@@ -101,7 +101,7 @@ class GeoShapeTest < Minitest::Test @@ -101,7 +101,7 @@ class GeoShapeTest < Minitest::Test
101 } 101 }
102 } 102 }
103 } 103 }
104 - }, Region 104 + }
105 end 105 end
106 106
107 def test_within 107 def test_within
@@ -115,7 +115,7 @@ class GeoShapeTest < Minitest::Test @@ -115,7 +115,7 @@ class GeoShapeTest < Minitest::Test
115 } 115 }
116 } 116 }
117 } 117 }
118 - }, Region 118 + }
119 end 119 end
120 120
121 def test_search_math 121 def test_search_math
@@ -128,7 +128,7 @@ class GeoShapeTest < Minitest::Test @@ -128,7 +128,7 @@ class GeoShapeTest < Minitest::Test
128 } 128 }
129 } 129 }
130 } 130 }
131 - }, Region 131 + }
132 end 132 end
133 133
134 def test_search_no_match 134 def test_search_no_match
@@ -141,7 +141,7 @@ class GeoShapeTest < Minitest::Test @@ -141,7 +141,7 @@ class GeoShapeTest < Minitest::Test
141 } 141 }
142 } 142 }
143 } 143 }
144 - }, Region 144 + }
145 end 145 end
146 146
147 def test_contains 147 def test_contains
@@ -158,7 +158,7 @@ class GeoShapeTest < Minitest::Test @@ -158,7 +158,7 @@ class GeoShapeTest < Minitest::Test
158 } 158 }
159 } 159 }
160 } 160 }
161 - }, Region 161 + }
162 end 162 end
163 163
164 def test_latlon 164 def test_latlon
@@ -171,7 +171,10 @@ class GeoShapeTest < Minitest::Test @@ -171,7 +171,10 @@ class GeoShapeTest < Minitest::Test
171 } 171 }
172 } 172 }
173 } 173 }
174 - }, Region 174 + }
175 end 175 end
176 176
  177 + def default_model
  178 + Region
  179 + end
177 end 180 end
test/test_helper.rb
@@ -74,7 +74,7 @@ class Minitest::Test @@ -74,7 +74,7 @@ class Minitest::Test
74 74
75 protected 75 protected
76 76
77 - def store(documents, klass = Product, reindex: true) 77 + def store(documents, klass = default_model, reindex: true)
78 if reindex 78 if reindex
79 documents.shuffle.each do |document| 79 documents.shuffle.each do |document|
80 klass.create!(document) 80 klass.create!(document)