rats 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,84 +1,76 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe Rats::Meridian do
4
-
5
4
  it "initializes" do
6
5
  data = Rats::Meridian.new
7
6
  data.is_a?(Rats::Meridian).should be_true
8
7
  end
9
-
8
+
10
9
  describe "boundaries" do
11
-
12
10
  it "knows valid data" do
13
11
  data = Rats::Meridian.new(6)
14
12
  data.valid?.should be_true
15
13
  end
16
-
14
+
17
15
  it "knows invalid data" do
18
16
  data = Rats::Meridian.new(3)
19
17
  data.valid?.should be_false
20
18
  data.error.should == "not allowed"
21
19
  end
22
-
20
+
23
21
  it "raises error with invalid data" do
24
22
  data = Rats::Meridian.new
25
23
  data.raise_errors!
26
24
  lambda { data.value = 3 }.should raise_error(ArgumentError)
27
25
  end
28
-
29
26
  end
30
-
27
+
31
28
  describe "read/write" do
32
-
33
29
  it "returns a padded value" do
34
30
  data = Rats::Meridian.new('4')
35
31
  data.to_p.should == '4'
36
32
  end
37
-
33
+
38
34
  it "returns the integer" do
39
35
  data = Rats::Meridian.new('4')
40
36
  data.v.should == 4
41
37
  end
42
-
38
+
43
39
  it "returns a string" do
44
40
  data = Rats::Meridian.new('4')
45
41
  data.to_s.should == 'W4'
46
42
  end
47
-
43
+
48
44
  it "writes just the integer" do
49
45
  data = Rats::Meridian.new('W4')
50
46
  data.v.should == 4
51
47
  end
52
-
48
+
53
49
  it "writes the fullname" do
54
50
  data = Rats::Meridian.new('W4')
55
51
  data.fullname.should == 'West of the Fourth Meridian'
56
52
  end
57
-
53
+
58
54
  describe "transforming" do
59
-
60
55
  it "accepts integers" do
61
56
  Rats::Meridian.transform(4).should == 4
62
57
  end
63
-
58
+
64
59
  it "accepts strings" do
65
60
  Rats::Meridian.transform('4').should == 4
66
61
  end
67
-
62
+
68
63
  it "accepts string prepended W" do
69
64
  Rats::Meridian.transform('W4').should == 4
70
65
  end
71
-
66
+
72
67
  it "accepts string prepended w" do
73
68
  Rats::Meridian.transform('w4').should == 4
74
69
  end
75
-
70
+
76
71
  it "doesn't accept other data" do
77
72
  Rats::Meridian.transform('E4').should be_nil
78
73
  end
79
-
80
74
  end
81
-
82
75
  end
83
-
84
- end
76
+ end
@@ -1,43 +1,39 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe Rats::Quarter do
4
-
5
4
  it "initializes" do
6
5
  data = Rats::Quarter.new
7
6
  data.is_a?(Rats::Quarter).should be_true
8
7
  end
9
-
8
+
10
9
  it "returns the full_name" do
11
10
  data = Rats::Quarter.new('NE')
12
11
  data.fullname.should == "the Northeast Quarter"
13
12
  end
14
-
13
+
15
14
  it "detects half" do
16
15
  Rats::Quarter.half?('NE').should be_false
17
16
  Rats::Quarter.half?('N').should be_true
18
17
  Rats::Quarter.half?('North').should be_true
19
18
  end
20
-
19
+
21
20
  it "transform input" do
22
21
  Rats::Quarter.transform('ne').should == 'NE'
23
22
  Rats::Quarter.transform('north').should == 'N'
24
23
  Rats::Quarter.transform('n').should == 'N'
25
24
  end
26
-
25
+
27
26
  describe "boundaries" do
28
-
29
27
  it "knows valid data" do
30
28
  data = Rats::Quarter.new('NE')
31
29
  data.valid?.should be_true
32
30
  data.error.should be_nil
33
31
  end
34
-
32
+
35
33
  it "knows invalid data" do
36
34
  data = Rats::Quarter.new('bad')
37
35
  data.valid?.should be_false
38
36
  data.error.should == "not allowed"
39
37
  end
40
-
41
38
  end
42
-
43
- end
39
+ end
@@ -1,66 +1,58 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe Rats::Range do
4
-
5
4
  it "initializes" do
6
5
  data = Rats::Range.new
7
6
  data.is_a?(Rats::Range).should be_true
8
7
  end
9
-
8
+
10
9
  describe "boundaries" do
11
-
12
10
  it "knows valid data" do
13
11
  data = Rats::Range.new(6)
14
12
  data.valid?.should be_true
15
13
  data.error.should be_nil
16
14
  end
17
-
15
+
18
16
  it "knows invalid data" do
19
17
  data = Rats::Range.new(31)
20
18
  data.valid?.should be_false
21
19
  data.error.should == "not allowed"
22
20
  end
23
-
24
21
  end
25
-
22
+
26
23
  describe "read/write" do
27
-
28
24
  it "returns a padded value" do
29
25
  data = Rats::Range.new('4')
30
26
  data.to_p.should == '04'
31
27
  end
32
-
28
+
33
29
  it "returns the integer" do
34
30
  data = Rats::Range.new('4')
35
31
  data.v.should == 4
36
32
  end
37
-
33
+
38
34
  it "returns a string" do
39
35
  data = Rats::Range.new('4')
40
36
  data.to_s.should == '4'
41
37
  end
42
-
38
+
43
39
  it "writes the fullname" do
44
40
  data = Rats::Range.new('4')
45
41
  data.fullname.should == 'Range 4'
46
42
  end
47
-
43
+
48
44
  describe "transforming" do
49
-
50
45
  it "accepts integers" do
51
46
  Rats::Range.transform(4).should == 4
52
47
  end
53
-
48
+
54
49
  it "accepts strings" do
55
50
  Rats::Range.transform('4').should == 4
56
51
  end
57
-
52
+
58
53
  it "doesn't accept other data" do
59
54
  Rats::Range.transform('E4').should be_nil
60
55
  end
61
-
62
56
  end
63
-
64
57
  end
65
-
66
- end
58
+ end
@@ -1,66 +1,58 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe Rats::Section do
4
-
5
4
  it "initializes" do
6
5
  data = Rats::Section.new
7
6
  data.is_a?(Rats::Section).should be_true
8
7
  end
9
-
8
+
10
9
  describe "boundaries" do
11
-
12
10
  it "knows valid data" do
13
11
  data = Rats::Section.new(6)
14
12
  data.valid?.should be_true
15
13
  data.error.should be_nil
16
14
  end
17
-
15
+
18
16
  it "knows invalid data" do
19
17
  data = Rats::Section.new(37)
20
18
  data.valid?.should be_false
21
19
  data.error.should == "not allowed"
22
20
  end
23
-
24
21
  end
25
-
22
+
26
23
  describe "read/write" do
27
-
28
24
  it "returns a padded value" do
29
25
  data = Rats::Section.new('4')
30
26
  data.to_p.should == '04'
31
27
  end
32
-
28
+
33
29
  it "returns the integer" do
34
30
  data = Rats::Section.new('4')
35
31
  data.v.should == 4
36
32
  end
37
-
33
+
38
34
  it "returns a string" do
39
35
  data = Rats::Section.new('4')
40
36
  data.to_s.should == '4'
41
37
  end
42
-
38
+
43
39
  it "writes the fullname" do
44
40
  data = Rats::Section.new('4')
45
41
  data.fullname.should == 'Section 4'
46
42
  end
47
-
43
+
48
44
  describe "transforming" do
49
-
50
45
  it "accepts integers" do
51
46
  Rats::Section.transform(4).should == 4
52
47
  end
53
-
48
+
54
49
  it "accepts strings" do
55
50
  Rats::Section.transform('4').should == 4
56
51
  end
57
-
52
+
58
53
  it "doesn't accept other data" do
59
54
  Rats::Section.transform('E4').should be_nil
60
55
  end
61
-
62
56
  end
63
-
64
57
  end
65
-
66
- end
58
+ end
@@ -1,66 +1,58 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe Rats::Township do
4
-
5
4
  it "initializes" do
6
5
  data = Rats::Township.new
7
6
  data.is_a?(Rats::Township).should be_true
8
7
  end
9
-
8
+
10
9
  describe "boundaries" do
11
-
12
10
  it "knows valid data" do
13
11
  data = Rats::Township.new(6)
14
12
  data.valid?.should be_true
15
13
  data.error.should be_nil
16
14
  end
17
-
15
+
18
16
  it "knows invalid data" do
19
17
  data = Rats::Township.new(130)
20
18
  data.valid?.should be_false
21
19
  data.error.should == "not allowed"
22
20
  end
23
-
24
21
  end
25
-
22
+
26
23
  describe "read/write" do
27
-
28
24
  it "returns a padded value" do
29
25
  data = Rats::Township.new('4')
30
26
  data.to_p.should == '004'
31
27
  end
32
-
28
+
33
29
  it "returns the integer" do
34
30
  data = Rats::Township.new('4')
35
31
  data.v.should == 4
36
32
  end
37
-
33
+
38
34
  it "returns a string" do
39
35
  data = Rats::Township.new('4')
40
36
  data.to_s.should == '4'
41
37
  end
42
-
38
+
43
39
  it "writes the fullname" do
44
40
  data = Rats::Township.new('4')
45
41
  data.fullname.should == 'Township 4'
46
42
  end
47
-
43
+
48
44
  describe "transforming" do
49
-
50
45
  it "accepts integers" do
51
46
  Rats::Township.transform(4).should == 4
52
47
  end
53
-
48
+
54
49
  it "accepts strings" do
55
50
  Rats::Township.transform('4').should == 4
56
51
  end
57
-
52
+
58
53
  it "doesn't accept other data" do
59
54
  Rats::Township.transform('E4').should be_nil
60
55
  end
61
-
62
56
  end
63
-
64
57
  end
65
-
66
- end
58
+ end
@@ -1,51 +1,43 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
- describe "Rats" do
4
-
3
+ describe Rats do
5
4
  it "initializes the class" do
6
5
  land = Rats.new
7
6
  land.is_a?(Rats::Base).should be_true
8
7
  end
9
-
8
+
10
9
  describe "attributes" do
11
-
12
- before(:each) do
13
- @land = Rats.new
14
- end
15
-
10
+ let(:land) { Rats.new }
11
+
16
12
  describe "writing and reading" do
17
-
18
13
  it "writes quarter" do
19
- @land.quarter = "NE"
20
- @land.quarter.should == "NE"
14
+ land.quarter = "NE"
15
+ land.quarter.should == "NE"
21
16
  end
22
-
17
+
23
18
  it "writes section" do
24
- @land.section = 1
25
- @land.section.should == 1
19
+ land.section = 1
20
+ land.section.should == 1
26
21
  end
27
-
22
+
28
23
  it "writes township" do
29
- @land.township = 1
30
- @land.township.should == 1
24
+ land.township = 1
25
+ land.township.should == 1
31
26
  end
32
-
27
+
33
28
  it "writes range" do
34
- @land.range = 1
35
- @land.range.should == 1
29
+ land.range = 1
30
+ land.range.should == 1
36
31
  end
37
-
32
+
38
33
  it "writes meridian" do
39
- @land.meridian = 4
40
- @land.meridian.should == 4
34
+ land.meridian = 4
35
+ land.meridian.should == 4
41
36
  end
42
-
43
37
  end
44
-
45
38
  end
46
-
39
+
47
40
  describe "parsing locations" do
48
-
49
41
  it "understands NE 1-2-3 W4" do
50
42
  land = Rats.new("NE 1-2-3 W4")
51
43
  land.quarter.should == "NE"
@@ -55,7 +47,7 @@ describe "Rats" do
55
47
  land.meridian.should == 4
56
48
  land.scope.should == :quarter
57
49
  end
58
-
50
+
59
51
  it "understands NE-1-2-3-W4" do
60
52
  land = Rats.new("NE-1-2-3-W4")
61
53
  land.quarter.should == "NE"
@@ -65,7 +57,7 @@ describe "Rats" do
65
57
  land.meridian.should == 4
66
58
  land.scope.should == :quarter
67
59
  end
68
-
60
+
69
61
  it "understands NE-1-2-3-4" do
70
62
  land = Rats.new("NE-1-2-3-4")
71
63
  land.quarter.should == "NE"
@@ -75,7 +67,7 @@ describe "Rats" do
75
67
  land.meridian.should == 4
76
68
  land.scope.should == :quarter
77
69
  end
78
-
70
+
79
71
  it "understands NE 1-1-1-4" do
80
72
  land = Rats.new("NE 1-2-3-4")
81
73
  land.quarter.should == "NE"
@@ -85,7 +77,7 @@ describe "Rats" do
85
77
  land.meridian.should == 4
86
78
  land.scope.should == :quarter
87
79
  end
88
-
80
+
89
81
  it "understands NE 1 2 3 4" do
90
82
  land = Rats.new("NE 1 2 3 4")
91
83
  land.quarter.should == "NE"
@@ -95,7 +87,7 @@ describe "Rats" do
95
87
  land.meridian.should == 4
96
88
  land.scope.should == :quarter
97
89
  end
98
-
90
+
99
91
  it "understands N 1-2-3 W4" do
100
92
  land = Rats.new("N 1-2-3 W4")
101
93
  land.quarter.should == "N"
@@ -105,7 +97,7 @@ describe "Rats" do
105
97
  land.meridian.should == 4
106
98
  land.scope.should == :half
107
99
  end
108
-
100
+
109
101
  it "understands North 1-2-3 W4" do
110
102
  land = Rats.new("North 1-2-3 W4")
111
103
  land.quarter.should == "N"
@@ -115,7 +107,7 @@ describe "Rats" do
115
107
  land.meridian.should == 4
116
108
  land.scope.should == :half
117
109
  end
118
-
110
+
119
111
  it "understands 40300201NE" do
120
112
  land = Rats.new("40300201NE")
121
113
  land.quarter.should == "NE"
@@ -125,7 +117,7 @@ describe "Rats" do
125
117
  land.meridian.should == 4
126
118
  land.scope.should == :quarter
127
119
  end
128
-
120
+
129
121
  it "understands 40300201" do
130
122
  land = Rats.new("40300201")
131
123
  land.quarter.should be_nil
@@ -135,7 +127,7 @@ describe "Rats" do
135
127
  land.meridian.should == 4
136
128
  land.scope.should == :section
137
129
  end
138
-
130
+
139
131
  it "understands 1-2-3 W4" do
140
132
  land = Rats.new("1-2-3 W4")
141
133
  land.quarter.should be_nil
@@ -145,7 +137,7 @@ describe "Rats" do
145
137
  land.meridian.should == 4
146
138
  land.scope.should == :section
147
139
  end
148
-
140
+
149
141
  it "understands 2-3 W4" do
150
142
  land = Rats.new("2-3 W4")
151
143
  land.quarter.should be_nil
@@ -155,7 +147,7 @@ describe "Rats" do
155
147
  land.meridian.should == 4
156
148
  land.scope.should == :township
157
149
  end
158
-
150
+
159
151
  it "understands 3 W4" do
160
152
  land = Rats.new("3 W4")
161
153
  land.quarter.should be_nil
@@ -165,7 +157,7 @@ describe "Rats" do
165
157
  land.meridian.should == 4
166
158
  land.scope.should == :unknown
167
159
  end
168
-
160
+
169
161
  it "understands W4" do
170
162
  land = Rats.new("W4")
171
163
  land.quarter.should be_nil
@@ -175,7 +167,7 @@ describe "Rats" do
175
167
  land.meridian.should == 4
176
168
  land.scope.should == :unknown
177
169
  end
178
-
170
+
179
171
  it "understands individual values" do
180
172
  land = Rats.new(4, 3, 2, 1, "NE")
181
173
  land.quarter.should == "NE"
@@ -185,7 +177,7 @@ describe "Rats" do
185
177
  land.meridian.should == 4
186
178
  land.scope.should == :quarter
187
179
  end
188
-
180
+
189
181
  it "understands SE 1-119-24 W4" do
190
182
  land = Rats.new("SE 1-119-24 W4")
191
183
  land.quarter.should == "SE"
@@ -195,9 +187,9 @@ describe "Rats" do
195
187
  land.meridian.should == 4
196
188
  land.scope.should == :quarter
197
189
  end
198
-
190
+
199
191
  describe "alternate method" do
200
-
192
+
201
193
  it "using location and a string" do
202
194
  land = Rats.new
203
195
  land.location = "NE 1-2-3 W4"
@@ -217,46 +209,36 @@ describe "Rats" do
217
209
  land.range.should == 3
218
210
  land.meridian.should == 4
219
211
  end
220
-
221
212
  end
222
-
223
213
  end
224
-
214
+
225
215
  describe "validation (does it exist)" do
226
-
227
- # each individual field has already been tested to know what is a valid field
228
- # here, I am testing the location as a whole, as a location can be valid
229
- # in respect to its individual components, but not as a whole
230
-
231
216
  it "knows a valid and existing location" do
232
217
  land = Rats.new("SE 1-2-3 W4")
233
218
  land.location.should == "SE 1-2-3 W4"
234
219
  land.exists?.should be_true
235
220
  end
236
-
221
+
237
222
  it "knows an non-existing section (in a valid township)" do
238
223
  land = Rats.new("SE 2-119-24 W4")
239
224
  land.exists?.should be_false
240
-
241
- # but it neightbour does
225
+
242
226
  land = Rats.new("SE 1-119-24 W4")
243
227
  land.exists?.should be_true
244
228
  end
245
-
229
+
246
230
  it "knows an non-existing township (in a valid range)" do
247
231
  land = Rats.new("SE 1-19-30 W4")
248
232
  land.exists?.should be_false
249
233
  end
250
-
234
+
251
235
  it "knows an non-existing range (in a valid township)" do
252
236
  land = Rats.new("SE 1-20-30 W4")
253
237
  land.exists?.should be_false
254
238
  end
255
-
256
239
  end
257
-
240
+
258
241
  describe "boundaries" do
259
-
260
242
  it "knows when a township is North of Alberta" do
261
243
  land = Rats.new("SE 1-127-1 W4")
262
244
  land.valid?.should be_false
@@ -264,7 +246,7 @@ describe "Rats" do
264
246
  land.errors.has_key?(:township).should be_true
265
247
  land.errors[:township].first.should == 'not allowed'
266
248
  end
267
-
249
+
268
250
  it "knows when a township is East of Alberta" do
269
251
  land = Rats.new("SE 1-1-1 W3")
270
252
  land.valid?.should be_false
@@ -272,7 +254,7 @@ describe "Rats" do
272
254
  land.errors.has_key?(:meridian).should be_true
273
255
  land.errors[:meridian].first.should == 'not allowed'
274
256
  end
275
-
257
+
276
258
  it "knows when a township is West of Alberta" do
277
259
  land = Rats.new("SE 1-1-1 W7")
278
260
  land.valid?.should be_false
@@ -280,7 +262,7 @@ describe "Rats" do
280
262
  land.errors.has_key?(:meridian).should be_true
281
263
  land.errors[:meridian].first.should == 'not allowed'
282
264
  end
283
-
265
+
284
266
  it "knows when a township has been squeezed out" do
285
267
  land = Rats.new("SE 1-126-25 W4")
286
268
  land.valid?.should be_false
@@ -288,7 +270,7 @@ describe "Rats" do
288
270
  land.errors.has_key?(:land).should be_true
289
271
  land.errors[:land].first.should == 'does not exist'
290
272
  end
291
-
273
+
292
274
  it "knows when a section has been squeezed out" do
293
275
  land = Rats.new("SE 6-119-24 W4")
294
276
  land.valid?.should be_false
@@ -296,40 +278,32 @@ describe "Rats" do
296
278
  land.errors.has_key?(:land).should be_true
297
279
  land.errors[:land].first.should == 'does not exist'
298
280
  end
299
-
300
- # it "knows when a quarter has been squeezed out" do
301
- # end
302
-
303
281
  end
304
-
282
+
305
283
  describe "formatting" do
306
-
307
284
  describe ":default" do
308
-
309
285
  it "returns NE 1-2-3 W4" do
310
286
  land = Rats.new("NE 1-2-3 W4")
311
287
  land.location.should == "NE 1-2-3 W4"
312
288
  end
313
-
289
+
314
290
  it "returns 1-2-3 W4" do
315
291
  land = Rats.new("1-2-3 W4")
316
292
  land.location.should == "1-2-3 W4"
317
293
  end
318
-
294
+
319
295
  it "returns 2-3 W4" do
320
296
  land = Rats.new("2-3 W4")
321
297
  land.location.should == "2-3 W4"
322
298
  end
323
-
324
299
  end
325
-
300
+
326
301
  describe ":short" do
327
-
328
302
  it "returns NE01002034" do
329
303
  land = Rats.new("NE 1-2-3 W4")
330
304
  land.location(:short).should == "40300201NE"
331
305
  end
332
-
306
+
333
307
  it "returns 01001014" do
334
308
  land = Rats.new("1-2-3 W4")
335
309
  land.location(:short).should == "40300201"
@@ -339,122 +313,107 @@ describe "Rats" do
339
313
  land = Rats.new("2-3 W4")
340
314
  land.location(:short).should == "403002"
341
315
  end
342
-
343
316
  end
344
-
317
+
345
318
  describe ":padded" do
346
-
347
319
  it "returns NE 01-002-03 W4" do
348
320
  land = Rats.new("NE 1-2-3 W4")
349
321
  land.location(:padded).should == "NE 01-002-03 W4"
350
322
  end
351
-
323
+
352
324
  it "returns 01-002-03 W4" do
353
325
  land = Rats.new("1-2-3 W4")
354
326
  land.location(:padded).should == "01-002-03 W4"
355
327
  end
356
-
328
+
357
329
  it "returns 002-03 W4" do
358
330
  land = Rats.new("2-3 W4")
359
331
  land.location(:padded).should == "002-03 W4"
360
332
  end
361
-
362
333
  end
363
-
334
+
364
335
  describe ":long" do
365
-
366
336
  it "returns the long version with Quarter" do
367
337
  land = Rats.new("NE 1-2-3 W4")
368
338
  land.location(:long).should == "the Northeast Quarter of Section 1, Township 2, Range 3, West of the Fourth Meridian"
369
339
  end
370
-
340
+
371
341
  it "returns the long version with Half" do
372
342
  land = Rats.new("N 1-2-3 W4")
373
343
  land.location(:long).should == "the North Half of Section 1, Township 2, Range 3, West of the Fourth Meridian"
374
344
  end
375
-
345
+
376
346
  it "returns the long version with Section" do
377
347
  land = Rats.new("1-2-3 W4")
378
- #puts land.inspect
379
348
  land.location(:long).should == "Section 1, Township 2, Range 3, West of the Fourth Meridian"
380
349
  end
381
-
350
+
382
351
  it "returns the long version with Township" do
383
352
  land = Rats.new("2-3 W4")
384
- #puts land.inspect
385
353
  land.location(:long).should == "Township 2, Range 3, West of the Fourth Meridian"
386
354
  end
387
-
388
355
  end
389
-
390
356
  end
391
-
357
+
392
358
  describe "scope" do
393
-
394
359
  it "knows quarter" do
395
360
  land = Rats.new("NE 1-2-3 W4")
396
361
  land.scope.should == :quarter
397
362
  end
398
-
363
+
399
364
  it "knows half" do
400
365
  land = Rats.new("E 1-2-3 W4")
401
366
  land.scope.should == :half
402
367
  end
403
-
368
+
404
369
  it "knows half" do
405
370
  land = Rats.new("East 1-2-3 W4")
406
371
  land.scope.should == :half
407
372
  end
408
-
373
+
409
374
  it "knows section" do
410
375
  land = Rats.new("1-2-3 W4")
411
376
  land.scope.should == :section
412
377
  end
413
-
378
+
414
379
  it "knows township" do
415
380
  land = Rats.new("2-3 W4")
416
381
  land.scope.should == :township
417
382
  end
418
-
383
+
419
384
  it "anything else is unknown" do
420
385
  land = Rats.new("3 W4")
421
386
  land.scope.should == :unknown
422
387
  end
423
-
424
388
  end
425
-
389
+
426
390
  describe "methods" do
427
-
428
391
  describe "validity" do
429
-
430
392
  it "knows when it is valid" do
431
393
  land = Rats.new("NE 1-2-3 W4")
432
394
  land.valid?.should be_true
433
395
  end
434
-
396
+
435
397
  it "knows when it isn't valid"do
436
398
  land = Rats.new("3 W4")
437
- #puts land.inspect
438
399
  land.valid?.should be_false
439
400
  end
440
-
441
401
  end
442
-
402
+
443
403
  it "responds_to :to_s" do
444
404
  land = Rats.new("NE 1-2-3 W4")
445
405
  land.to_s.should == land.location
446
406
  end
447
-
407
+
448
408
  it "responds_to :to_a" do
449
409
  land = Rats.new("NE 1-2-3 W4")
450
410
  land.to_a.should == ['NE', 1, 2, 3, 4]
451
-
411
+
452
412
  land = Rats.new("1-2-3 W4")
453
413
  land.to_a.should == [1, 2, 3, 4]
454
414
  end
455
-
415
+
456
416
  describe "expansion" do
457
-
458
417
  it "is divisible" do
459
418
  Rats.new("N 1-2-3 W4").is_divisible?.should be_true
460
419
  Rats.new("NSE 1-2-3 W4").is_divisible?.should be_true
@@ -462,20 +421,20 @@ describe "Rats" do
462
421
  Rats.new("1-2-3 W4").is_divisible?.should be_true
463
422
  Rats.new("2-3 W4").is_divisible?.should be_true
464
423
  end
465
-
424
+
466
425
  it "is not divisible" do
467
426
  Rats.new("NE 1-2-3 W4").is_divisible?.should be_false
468
427
  Rats.new("3 W4").is_divisible?.should be_false
469
428
  Rats.new("W4").is_divisible?.should be_false
470
429
  end
471
-
430
+
472
431
  describe "half -> 2 quarters" do
473
432
  quarters = Rats.new("N 1-2-3 W4").divide
474
433
  quarters.size.should == 2
475
434
  quarters.first.quarter.should == 'NE'
476
435
  quarters.last.quarter.should == 'NW'
477
436
  end
478
-
437
+
479
438
  describe "3/4 -> 3 quarters" do
480
439
  quarters = Rats.new("NSE 1-2-3 W4").divide
481
440
  quarters.size.should == 3
@@ -483,7 +442,7 @@ describe "Rats" do
483
442
  quarters[1].quarter.should == 'NW'
484
443
  quarters[2].quarter.should == 'SE'
485
444
  end
486
-
445
+
487
446
  describe "section -> 4 quarters" do
488
447
  quarters = Rats.new("1-2-3 W4").divide
489
448
  quarters.size.should == 4
@@ -492,7 +451,7 @@ describe "Rats" do
492
451
  quarters[2].quarter.should == 'SE'
493
452
  quarters[3].quarter.should == 'SW'
494
453
  end
495
-
454
+
496
455
  describe "ALL -> 4 quarters" do
497
456
  quarters = Rats.new("ALL 1-2-3 W4").divide
498
457
  quarters.size.should == 4
@@ -501,14 +460,11 @@ describe "Rats" do
501
460
  quarters[2].quarter.should == 'SE'
502
461
  quarters[3].quarter.should == 'SW'
503
462
  end
504
-
463
+
505
464
  describe "township -> 144 quarters" do
506
465
  quarters = Rats.new("2-3 W4").divide
507
466
  quarters.size.should == 144
508
467
  end
509
-
510
468
  end
511
-
512
469
  end
513
-
514
470
  end