ruby-measurement 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,63 +5,63 @@ require 'spec_helper'
5
5
  RSpec.describe Measurement do
6
6
  describe 'acre-feet' do
7
7
  subject { described_class.parse('1 acre ft') }
8
-
8
+
9
9
  it 'converts to cubic yards' do
10
10
  expect(subject.convert_to(:yd3).quantity).to eq Rational(4840, 3).to_f
11
11
  end
12
-
12
+
13
13
  it 'converts to cubic feet' do
14
14
  expect(subject.convert_to(:ft3).quantity).to eq 43_560
15
15
  end
16
-
16
+
17
17
  it 'converts to cubic inches' do
18
18
  expect(subject.convert_to(:in3).quantity).to eq 75_271_680
19
19
  end
20
20
  end
21
-
21
+
22
22
  describe 'cubic yards' do
23
23
  subject { described_class.parse('1613 1/3 yd³') }
24
-
24
+
25
25
  it 'converts to acre-feet' do
26
26
  expect(subject.convert_to(:'acre ft').quantity).to eq 1
27
27
  end
28
-
28
+
29
29
  it 'converts to cubic feet' do
30
30
  expect(subject.convert_to(:ft3).quantity).to eq 43_560
31
31
  end
32
-
32
+
33
33
  it 'converts to cubic inches' do
34
34
  expect(subject.convert_to(:in3).quantity).to eq 75_271_680
35
35
  end
36
36
  end
37
-
37
+
38
38
  describe 'cubic feet' do
39
39
  subject { described_class.parse('43560 ft³') }
40
-
40
+
41
41
  it 'converts to acre-feet' do
42
42
  expect(subject.convert_to(:'acre ft').quantity).to eq 1
43
43
  end
44
-
44
+
45
45
  it 'converts to cubic yards' do
46
46
  expect(subject.convert_to(:yd3).quantity).to eq Rational(4840, 3).to_f
47
47
  end
48
-
48
+
49
49
  it 'converts to cubic inches' do
50
50
  expect(subject.convert_to(:in3).quantity).to eq 75_271_680
51
51
  end
52
52
  end
53
-
53
+
54
54
  describe 'cubic inches' do
55
55
  subject { described_class.parse('75271680 in³') }
56
-
56
+
57
57
  it 'converts to acre-feet' do
58
58
  expect(subject.convert_to(:'acre ft').quantity).to eq 1
59
59
  end
60
-
60
+
61
61
  it 'converts to cubic yards' do
62
62
  expect(subject.convert_to(:yd3).quantity).to eq Rational(4840, 3).to_f
63
63
  end
64
-
64
+
65
65
  it 'converts to cubic feet' do
66
66
  expect(subject.convert_to(:ft3).quantity).to eq 43_560
67
67
  end
@@ -5,255 +5,255 @@ require 'spec_helper'
5
5
  RSpec.describe Measurement do
6
6
  describe 'miles' do
7
7
  subject { described_class.parse('1 mi') }
8
-
8
+
9
9
  it 'converts to furlongs' do
10
10
  expect(subject.convert_to(:fur).quantity).to eq 8
11
11
  end
12
-
12
+
13
13
  it 'converts to chains' do
14
14
  expect(subject.convert_to(:ch).quantity).to eq 80
15
15
  end
16
-
16
+
17
17
  it 'converts to fathoms' do
18
18
  expect(subject.convert_to(:ftm).quantity).to eq 880
19
19
  end
20
-
20
+
21
21
  it 'converts to yards' do
22
22
  expect(subject.convert_to(:yd).quantity).to eq 1_760
23
23
  end
24
-
24
+
25
25
  it 'converts to feet' do
26
26
  expect(subject.convert_to(:ft).quantity).to eq 5_280
27
27
  end
28
-
28
+
29
29
  it 'converts to inches' do
30
30
  expect(subject.convert_to(:in).quantity).to eq 63_360
31
31
  end
32
-
32
+
33
33
  it 'converts to thou' do
34
34
  expect(subject.convert_to(:th).quantity).to eq 63_360_000
35
35
  end
36
36
  end
37
-
37
+
38
38
  describe 'furlongs' do
39
39
  subject { described_class.parse('8 fur') }
40
-
40
+
41
41
  it 'converts to miles' do
42
42
  expect(subject.convert_to(:mi).quantity).to eq 1
43
43
  end
44
-
44
+
45
45
  it 'converts to chains' do
46
46
  expect(subject.convert_to(:ch).quantity).to eq 80
47
47
  end
48
-
48
+
49
49
  it 'converts to fathoms' do
50
50
  expect(subject.convert_to(:ftm).quantity).to eq 880
51
51
  end
52
-
52
+
53
53
  it 'converts to yards' do
54
54
  expect(subject.convert_to(:yd).quantity).to eq 1_760
55
55
  end
56
-
56
+
57
57
  it 'converts to feet' do
58
58
  expect(subject.convert_to(:ft).quantity).to eq 5_280
59
59
  end
60
-
60
+
61
61
  it 'converts to inches' do
62
62
  expect(subject.convert_to(:in).quantity).to eq 63_360
63
63
  end
64
-
64
+
65
65
  it 'converts to thou' do
66
66
  expect(subject.convert_to(:th).quantity).to eq 63_360_000
67
67
  end
68
68
  end
69
-
69
+
70
70
  describe 'chains' do
71
71
  subject { described_class.parse('80 ch') }
72
-
72
+
73
73
  it 'converts to miles' do
74
74
  expect(subject.convert_to(:mi).quantity).to eq 1
75
75
  end
76
-
76
+
77
77
  it 'converts to furlongs' do
78
78
  expect(subject.convert_to(:fur).quantity).to eq 8
79
79
  end
80
-
80
+
81
81
  it 'converts to fathoms' do
82
82
  expect(subject.convert_to(:ftm).quantity).to eq 880
83
83
  end
84
-
84
+
85
85
  it 'converts to yards' do
86
86
  expect(subject.convert_to(:yd).quantity).to eq 1_760
87
87
  end
88
-
88
+
89
89
  it 'converts to feet' do
90
90
  expect(subject.convert_to(:ft).quantity).to eq 5_280
91
91
  end
92
-
92
+
93
93
  it 'converts to inches' do
94
94
  expect(subject.convert_to(:in).quantity).to eq 63_360
95
95
  end
96
-
96
+
97
97
  it 'converts to thou' do
98
98
  expect(subject.convert_to(:th).quantity).to eq 63_360_000
99
99
  end
100
100
  end
101
-
101
+
102
102
  describe 'fathoms' do
103
103
  subject { described_class.parse('880 ftm') }
104
-
104
+
105
105
  it 'converts to miles' do
106
106
  expect(subject.convert_to(:mi).quantity).to eq 1
107
107
  end
108
-
108
+
109
109
  it 'converts to furlongs' do
110
110
  expect(subject.convert_to(:fur).quantity).to eq 8
111
111
  end
112
-
112
+
113
113
  it 'converts to chains' do
114
114
  expect(subject.convert_to(:ch).quantity).to eq 80
115
115
  end
116
-
116
+
117
117
  it 'converts to yards' do
118
118
  expect(subject.convert_to(:yd).quantity).to eq 1_760
119
119
  end
120
-
120
+
121
121
  it 'converts to feet' do
122
122
  expect(subject.convert_to(:ft).quantity).to eq 5_280
123
123
  end
124
-
124
+
125
125
  it 'converts to inches' do
126
126
  expect(subject.convert_to(:in).quantity).to eq 63_360
127
127
  end
128
-
128
+
129
129
  it 'converts to thou' do
130
130
  expect(subject.convert_to(:th).quantity).to eq 63_360_000
131
131
  end
132
132
  end
133
-
133
+
134
134
  describe 'yards' do
135
135
  subject { described_class.parse('1760 yd') }
136
-
136
+
137
137
  it 'converts to miles' do
138
138
  expect(subject.convert_to(:mi).quantity).to eq 1
139
139
  end
140
-
140
+
141
141
  it 'converts to furlongs' do
142
142
  expect(subject.convert_to(:fur).quantity).to eq 8
143
143
  end
144
-
144
+
145
145
  it 'converts to chains' do
146
146
  expect(subject.convert_to(:ch).quantity).to eq 80
147
147
  end
148
-
148
+
149
149
  it 'converts to fathoms' do
150
150
  expect(subject.convert_to(:ftm).quantity).to eq 880
151
151
  end
152
-
152
+
153
153
  it 'converts to feet' do
154
154
  expect(subject.convert_to(:ft).quantity).to eq 5_280
155
155
  end
156
-
156
+
157
157
  it 'converts to inches' do
158
158
  expect(subject.convert_to(:in).quantity).to eq 63_360
159
159
  end
160
-
160
+
161
161
  it 'converts to thou' do
162
162
  expect(subject.convert_to(:th).quantity).to eq 63_360_000
163
163
  end
164
164
  end
165
-
165
+
166
166
  describe 'feet' do
167
167
  subject { described_class.parse('5280 ft') }
168
-
168
+
169
169
  it 'converts to miles' do
170
170
  expect(subject.convert_to(:mi).quantity).to eq 1
171
171
  end
172
-
172
+
173
173
  it 'converts to furlongs' do
174
174
  expect(subject.convert_to(:fur).quantity).to eq 8
175
175
  end
176
-
176
+
177
177
  it 'converts to chains' do
178
178
  expect(subject.convert_to(:ch).quantity).to eq 80
179
179
  end
180
-
180
+
181
181
  it 'converts to fathoms' do
182
182
  expect(subject.convert_to(:ftm).quantity).to eq 880
183
183
  end
184
-
184
+
185
185
  it 'converts to yards' do
186
186
  expect(subject.convert_to(:yd).quantity).to eq 1_760
187
187
  end
188
-
188
+
189
189
  it 'converts to inches' do
190
190
  expect(subject.convert_to(:in).quantity).to eq 63_360
191
191
  end
192
-
192
+
193
193
  it 'converts to thou' do
194
194
  expect(subject.convert_to(:th).quantity).to eq 63_360_000
195
195
  end
196
196
  end
197
-
197
+
198
198
  describe 'inches' do
199
199
  subject { described_class.parse('63360 in') }
200
-
200
+
201
201
  it 'converts to miles' do
202
202
  expect(subject.convert_to(:mi).quantity).to eq 1
203
203
  end
204
-
204
+
205
205
  it 'converts to furlongs' do
206
206
  expect(subject.convert_to(:fur).quantity).to eq 8
207
207
  end
208
-
208
+
209
209
  it 'converts to chains' do
210
210
  expect(subject.convert_to(:ch).quantity).to eq 80
211
211
  end
212
-
212
+
213
213
  it 'converts to fathoms' do
214
214
  expect(subject.convert_to(:ftm).quantity).to eq 880
215
215
  end
216
-
216
+
217
217
  it 'converts to yards' do
218
218
  expect(subject.convert_to(:yd).quantity).to eq 1_760
219
219
  end
220
-
220
+
221
221
  it 'converts to feet' do
222
222
  expect(subject.convert_to(:ft).quantity).to eq 5_280
223
223
  end
224
-
224
+
225
225
  it 'converts to thou' do
226
226
  expect(subject.convert_to(:th).quantity).to eq 63_360_000
227
227
  end
228
228
  end
229
-
229
+
230
230
  describe 'thou' do
231
231
  subject { described_class.parse('63360000 th') }
232
-
232
+
233
233
  it 'converts to miles' do
234
234
  expect(subject.convert_to(:mi).quantity).to eq 1
235
235
  end
236
-
236
+
237
237
  it 'converts to furlongs' do
238
238
  expect(subject.convert_to(:fur).quantity).to eq 8
239
239
  end
240
-
240
+
241
241
  it 'converts to chains' do
242
242
  expect(subject.convert_to(:ch).quantity).to eq 80
243
243
  end
244
-
244
+
245
245
  it 'converts to fathoms' do
246
246
  expect(subject.convert_to(:ftm).quantity).to eq 880
247
247
  end
248
-
248
+
249
249
  it 'converts to yards' do
250
250
  expect(subject.convert_to(:yd).quantity).to eq 1_760
251
251
  end
252
-
252
+
253
253
  it 'converts to feet' do
254
254
  expect(subject.convert_to(:ft).quantity).to eq 5_280
255
255
  end
256
-
256
+
257
257
  it 'converts to inches' do
258
258
  expect(subject.convert_to(:in).quantity).to eq 63_360
259
259
  end
@@ -5,195 +5,195 @@ require 'spec_helper'
5
5
  RSpec.describe Measurement do
6
6
  describe 'gallons' do
7
7
  subject { described_class.parse('1 gal') }
8
-
8
+
9
9
  it 'converts to quarts' do
10
10
  expect(subject.convert_to(:qt).quantity).to eq 4
11
11
  end
12
-
12
+
13
13
  it 'converts to pints' do
14
14
  expect(subject.convert_to(:pt).quantity).to eq 8
15
15
  end
16
-
16
+
17
17
  it 'converts to cups' do
18
18
  expect(subject.convert_to(:c).quantity).to eq 16
19
19
  end
20
-
20
+
21
21
  it 'converts to fluid ounces' do
22
22
  expect(subject.convert_to(:'fl oz').quantity).to eq 128
23
23
  end
24
-
24
+
25
25
  it 'converts to tablespoons' do
26
26
  expect(subject.convert_to(:tbsp).quantity).to eq 256
27
27
  end
28
-
28
+
29
29
  it 'converts to teaspoons' do
30
30
  expect(subject.convert_to(:tsp).quantity).to eq 768
31
31
  end
32
32
  end
33
-
33
+
34
34
  describe 'quarts' do
35
35
  subject { described_class.parse('4 qt') }
36
-
36
+
37
37
  it 'converts to gallons' do
38
38
  expect(subject.convert_to(:gal).quantity).to eq 1
39
39
  end
40
-
40
+
41
41
  it 'converts to pints' do
42
42
  expect(subject.convert_to(:pt).quantity).to eq 8
43
43
  end
44
-
44
+
45
45
  it 'converts to cups' do
46
46
  expect(subject.convert_to(:c).quantity).to eq 16
47
47
  end
48
-
48
+
49
49
  it 'converts to fluid ounces' do
50
50
  expect(subject.convert_to(:'fl oz').quantity).to eq 128
51
51
  end
52
-
52
+
53
53
  it 'converts to tablespoons' do
54
54
  expect(subject.convert_to(:tbsp).quantity).to eq 256
55
55
  end
56
-
56
+
57
57
  it 'converts to teaspoons' do
58
58
  expect(subject.convert_to(:tsp).quantity).to eq 768
59
59
  end
60
60
  end
61
-
61
+
62
62
  describe 'pints' do
63
63
  subject { described_class.parse('8 pt') }
64
-
64
+
65
65
  it 'converts to gallons' do
66
66
  expect(subject.convert_to(:gal).quantity).to eq 1
67
67
  end
68
-
68
+
69
69
  it 'converts to quarts' do
70
70
  expect(subject.convert_to(:qt).quantity).to eq 4
71
71
  end
72
-
72
+
73
73
  it 'converts to cups' do
74
74
  expect(subject.convert_to(:c).quantity).to eq 16
75
75
  end
76
-
76
+
77
77
  it 'converts to fluid ounces' do
78
78
  expect(subject.convert_to(:'fl oz').quantity).to eq 128
79
79
  end
80
-
80
+
81
81
  it 'converts to tablespoons' do
82
82
  expect(subject.convert_to(:tbsp).quantity).to eq 256
83
83
  end
84
-
84
+
85
85
  it 'converts to teaspoons' do
86
86
  expect(subject.convert_to(:tsp).quantity).to eq 768
87
87
  end
88
88
  end
89
-
89
+
90
90
  describe 'cups' do
91
91
  subject { described_class.parse('16 c') }
92
-
92
+
93
93
  it 'converts to gallons' do
94
94
  expect(subject.convert_to(:gal).quantity).to eq 1
95
95
  end
96
-
96
+
97
97
  it 'converts to quarts' do
98
98
  expect(subject.convert_to(:qt).quantity).to eq 4
99
99
  end
100
-
100
+
101
101
  it 'converts to pints' do
102
102
  expect(subject.convert_to(:pt).quantity).to eq 8
103
103
  end
104
-
104
+
105
105
  it 'converts to fluid ounces' do
106
106
  expect(subject.convert_to(:'fl oz').quantity).to eq 128
107
107
  end
108
-
108
+
109
109
  it 'converts to tablespoons' do
110
110
  expect(subject.convert_to(:tbsp).quantity).to eq 256
111
111
  end
112
-
112
+
113
113
  it 'converts to teaspoons' do
114
114
  expect(subject.convert_to(:tsp).quantity).to eq 768
115
115
  end
116
116
  end
117
-
117
+
118
118
  describe 'fluid ounces' do
119
119
  subject { described_class.parse('128 fl oz') }
120
-
120
+
121
121
  it 'converts to gallons' do
122
122
  expect(subject.convert_to(:gal).quantity).to eq 1
123
123
  end
124
-
124
+
125
125
  it 'converts to quarts' do
126
126
  expect(subject.convert_to(:qt).quantity).to eq 4
127
127
  end
128
-
128
+
129
129
  it 'converts to pints' do
130
130
  expect(subject.convert_to(:pt).quantity).to eq 8
131
131
  end
132
-
132
+
133
133
  it 'converts to cups' do
134
134
  expect(subject.convert_to(:c).quantity).to eq 16
135
135
  end
136
-
136
+
137
137
  it 'converts to tablespoons' do
138
138
  expect(subject.convert_to(:tbsp).quantity).to eq 256
139
139
  end
140
-
140
+
141
141
  it 'converts to teaspoons' do
142
142
  expect(subject.convert_to(:tsp).quantity).to eq 768
143
143
  end
144
144
  end
145
-
145
+
146
146
  describe 'tablespoons' do
147
147
  subject { described_class.parse('256 tbsp') }
148
-
148
+
149
149
  it 'converts to gallons' do
150
150
  expect(subject.convert_to(:gal).quantity).to eq 1
151
151
  end
152
-
152
+
153
153
  it 'converts to quarts' do
154
154
  expect(subject.convert_to(:qt).quantity).to eq 4
155
155
  end
156
-
156
+
157
157
  it 'converts to pints' do
158
158
  expect(subject.convert_to(:pt).quantity).to eq 8
159
159
  end
160
-
160
+
161
161
  it 'converts to cups' do
162
162
  expect(subject.convert_to(:c).quantity).to eq 16
163
163
  end
164
-
164
+
165
165
  it 'converts to fluid ounces' do
166
166
  expect(subject.convert_to(:'fl oz').quantity).to eq 128
167
167
  end
168
-
168
+
169
169
  it 'converts to teaspoons' do
170
170
  expect(subject.convert_to(:tsp).quantity).to eq 768
171
171
  end
172
172
  end
173
-
173
+
174
174
  describe 'teaspoons' do
175
175
  subject { described_class.parse('768 tsp') }
176
-
176
+
177
177
  it 'converts to gallons' do
178
178
  expect(subject.convert_to(:gal).quantity).to eq 1
179
179
  end
180
-
180
+
181
181
  it 'converts to quarts' do
182
182
  expect(subject.convert_to(:qt).quantity).to eq 4
183
183
  end
184
-
184
+
185
185
  it 'converts to pints' do
186
186
  expect(subject.convert_to(:pt).quantity).to eq 8
187
187
  end
188
-
188
+
189
189
  it 'converts to cups' do
190
190
  expect(subject.convert_to(:c).quantity).to eq 16
191
191
  end
192
-
192
+
193
193
  it 'converts to fluid ounces' do
194
194
  expect(subject.convert_to(:'fl oz').quantity).to eq 128
195
195
  end
196
-
196
+
197
197
  it 'converts to tablespoons' do
198
198
  expect(subject.convert_to(:tbsp).quantity).to eq 256
199
199
  end