ruby-measurement 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/CI.yml +30 -0
  3. data/CHANGELOG.md +25 -10
  4. data/README.md +13 -7
  5. data/lib/ruby-measurement/core_ext/string.rb +2 -2
  6. data/lib/ruby-measurement/core_ext/symbol.rb +1 -1
  7. data/lib/ruby-measurement/measurement.rb +101 -42
  8. data/lib/ruby-measurement/unit.rb +34 -28
  9. data/lib/ruby-measurement/version.rb +1 -1
  10. data/ruby-measurement.gemspec +5 -4
  11. data/spec/ruby-measurement/core_ext/numeric_spec.rb +2 -2
  12. data/spec/ruby-measurement/core_ext/string_spec.rb +12 -12
  13. data/spec/ruby-measurement/core_ext/symbol_spec.rb +3 -3
  14. data/spec/ruby-measurement/definitions/metric/area_spec.rb +32 -32
  15. data/spec/ruby-measurement/definitions/metric/capacity_spec.rb +18 -18
  16. data/spec/ruby-measurement/definitions/metric/length_spec.rb +128 -128
  17. data/spec/ruby-measurement/definitions/metric/volume_spec.rb +128 -128
  18. data/spec/ruby-measurement/definitions/metric/weight_spec.rb +160 -160
  19. data/spec/ruby-measurement/definitions/us_customary/area_spec.rb +72 -72
  20. data/spec/ruby-measurement/definitions/us_customary/capacity_spec.rb +32 -32
  21. data/spec/ruby-measurement/definitions/us_customary/length_spec.rb +128 -128
  22. data/spec/ruby-measurement/definitions/us_customary/volume_spec.rb +98 -98
  23. data/spec/ruby-measurement/definitions/us_customary/weight_spec.rb +72 -72
  24. data/spec/ruby-measurement/measurement_spec.rb +238 -164
  25. data/spec/ruby-measurement/unit_builder_spec.rb +35 -35
  26. data/spec/ruby-measurement/unit_spec.rb +84 -41
  27. data/tasks/rspec.rake +1 -1
  28. metadata +29 -25
  29. data/.travis.yml +0 -4
@@ -2,260 +2,260 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Measurement do
5
+ RSpec.describe Measurement do
6
6
  describe 'kiloliters' do
7
- subject { Measurement.parse('1 kl') }
8
-
7
+ subject { described_class.parse('1 kl') }
8
+
9
9
  it 'converts to hectoliters' do
10
- subject.convert_to(:hl).quantity.should eq 10
10
+ expect(subject.convert_to(:hl).quantity).to eq 10
11
11
  end
12
-
12
+
13
13
  it 'converts to dekaliters' do
14
- subject.convert_to(:dal).quantity.should eq 100
14
+ expect(subject.convert_to(:dal).quantity).to eq 100
15
15
  end
16
-
16
+
17
17
  it 'converts to liters' do
18
- subject.convert_to(:l).quantity.should eq 1_000
18
+ expect(subject.convert_to(:l).quantity).to eq 1_000
19
19
  end
20
-
20
+
21
21
  it 'converts to deciliters' do
22
- subject.convert_to(:dl).quantity.should eq 10_000
22
+ expect(subject.convert_to(:dl).quantity).to eq 10_000
23
23
  end
24
-
24
+
25
25
  it 'converts to centiliters' do
26
- subject.convert_to(:cl).quantity.should eq 100_000
26
+ expect(subject.convert_to(:cl).quantity).to eq 100_000
27
27
  end
28
-
28
+
29
29
  it 'converts to milliliters' do
30
- subject.convert_to(:ml).quantity.should eq 1_000_000
30
+ expect(subject.convert_to(:ml).quantity).to eq 1_000_000
31
31
  end
32
-
32
+
33
33
  it 'converts to microliters' do
34
- subject.convert_to(:µl).quantity.should eq 10_000_000
34
+ expect(subject.convert_to(:µl).quantity).to eq 10_000_000
35
35
  end
36
36
  end
37
-
37
+
38
38
  describe 'hectoliters' do
39
- subject { Measurement.parse('10 hl') }
40
-
39
+ subject { described_class.parse('10 hl') }
40
+
41
41
  it 'converts to kiloliters' do
42
- subject.convert_to(:kl).quantity.should eq 1
42
+ expect(subject.convert_to(:kl).quantity).to eq 1
43
43
  end
44
-
44
+
45
45
  it 'converts to dekaliters' do
46
- subject.convert_to(:dal).quantity.should eq 100
46
+ expect(subject.convert_to(:dal).quantity).to eq 100
47
47
  end
48
-
48
+
49
49
  it 'converts to liters' do
50
- subject.convert_to(:l).quantity.should eq 1_000
50
+ expect(subject.convert_to(:l).quantity).to eq 1_000
51
51
  end
52
-
52
+
53
53
  it 'converts to deciliters' do
54
- subject.convert_to(:dl).quantity.should eq 10_000
54
+ expect(subject.convert_to(:dl).quantity).to eq 10_000
55
55
  end
56
-
56
+
57
57
  it 'converts to centiliters' do
58
- subject.convert_to(:cl).quantity.should eq 100_000
58
+ expect(subject.convert_to(:cl).quantity).to eq 100_000
59
59
  end
60
-
60
+
61
61
  it 'converts to milliliters' do
62
- subject.convert_to(:ml).quantity.should eq 1_000_000
62
+ expect(subject.convert_to(:ml).quantity).to eq 1_000_000
63
63
  end
64
-
64
+
65
65
  it 'converts to microliters' do
66
- subject.convert_to(:µl).quantity.should eq 10_000_000
66
+ expect(subject.convert_to(:µl).quantity).to eq 10_000_000
67
67
  end
68
68
  end
69
-
69
+
70
70
  describe 'dekaliters' do
71
- subject { Measurement.parse('100 dal') }
72
-
71
+ subject { described_class.parse('100 dal') }
72
+
73
73
  it 'converts to kiloliters' do
74
- subject.convert_to(:kl).quantity.should eq 1
74
+ expect(subject.convert_to(:kl).quantity).to eq 1
75
75
  end
76
-
76
+
77
77
  it 'converts to hectoliters' do
78
- subject.convert_to(:hl).quantity.should eq 10
78
+ expect(subject.convert_to(:hl).quantity).to eq 10
79
79
  end
80
-
80
+
81
81
  it 'converts to liters' do
82
- subject.convert_to(:l).quantity.should eq 1_000
82
+ expect(subject.convert_to(:l).quantity).to eq 1_000
83
83
  end
84
-
84
+
85
85
  it 'converts to deciliters' do
86
- subject.convert_to(:dl).quantity.should eq 10_000
86
+ expect(subject.convert_to(:dl).quantity).to eq 10_000
87
87
  end
88
-
88
+
89
89
  it 'converts to centiliters' do
90
- subject.convert_to(:cl).quantity.should eq 100_000
90
+ expect(subject.convert_to(:cl).quantity).to eq 100_000
91
91
  end
92
-
92
+
93
93
  it 'converts to milliliters' do
94
- subject.convert_to(:ml).quantity.should eq 1_000_000
94
+ expect(subject.convert_to(:ml).quantity).to eq 1_000_000
95
95
  end
96
-
96
+
97
97
  it 'converts to microliters' do
98
- subject.convert_to(:µl).quantity.should eq 10_000_000
98
+ expect(subject.convert_to(:µl).quantity).to eq 10_000_000
99
99
  end
100
100
  end
101
-
101
+
102
102
  describe 'liters' do
103
- subject { Measurement.parse('1000 l') }
104
-
103
+ subject { described_class.parse('1000 l') }
104
+
105
105
  it 'converts to kiloliters' do
106
- subject.convert_to(:kl).quantity.should eq 1
106
+ expect(subject.convert_to(:kl).quantity).to eq 1
107
107
  end
108
-
108
+
109
109
  it 'converts to hectoliters' do
110
- subject.convert_to(:hl).quantity.should eq 10
110
+ expect(subject.convert_to(:hl).quantity).to eq 10
111
111
  end
112
-
112
+
113
113
  it 'converts to dekaliters' do
114
- subject.convert_to(:dal).quantity.should eq 100
114
+ expect(subject.convert_to(:dal).quantity).to eq 100
115
115
  end
116
-
116
+
117
117
  it 'converts to deciliters' do
118
- subject.convert_to(:dl).quantity.should eq 10_000
118
+ expect(subject.convert_to(:dl).quantity).to eq 10_000
119
119
  end
120
-
120
+
121
121
  it 'converts to centiliters' do
122
- subject.convert_to(:cl).quantity.should eq 100_000
122
+ expect(subject.convert_to(:cl).quantity).to eq 100_000
123
123
  end
124
-
124
+
125
125
  it 'converts to milliliters' do
126
- subject.convert_to(:ml).quantity.should eq 1_000_000
126
+ expect(subject.convert_to(:ml).quantity).to eq 1_000_000
127
127
  end
128
-
128
+
129
129
  it 'converts to microliters' do
130
- subject.convert_to(:µl).quantity.should eq 10_000_000
130
+ expect(subject.convert_to(:µl).quantity).to eq 10_000_000
131
131
  end
132
132
  end
133
-
133
+
134
134
  describe 'deciliters' do
135
- subject { Measurement.parse('10000 dl') }
136
-
135
+ subject { described_class.parse('10000 dl') }
136
+
137
137
  it 'converts to kiloliters' do
138
- subject.convert_to(:kl).quantity.should eq 1
138
+ expect(subject.convert_to(:kl).quantity).to eq 1
139
139
  end
140
-
140
+
141
141
  it 'converts to hectoliters' do
142
- subject.convert_to(:hl).quantity.should eq 10
142
+ expect(subject.convert_to(:hl).quantity).to eq 10
143
143
  end
144
-
144
+
145
145
  it 'converts to dekaliters' do
146
- subject.convert_to(:dal).quantity.should eq 100
146
+ expect(subject.convert_to(:dal).quantity).to eq 100
147
147
  end
148
-
148
+
149
149
  it 'converts to liters' do
150
- subject.convert_to(:l).quantity.should eq 1_000
150
+ expect(subject.convert_to(:l).quantity).to eq 1_000
151
151
  end
152
-
152
+
153
153
  it 'converts to centiliters' do
154
- subject.convert_to(:cl).quantity.should eq 100_000
154
+ expect(subject.convert_to(:cl).quantity).to eq 100_000
155
155
  end
156
-
156
+
157
157
  it 'converts to milliliters' do
158
- subject.convert_to(:ml).quantity.should eq 1_000_000
158
+ expect(subject.convert_to(:ml).quantity).to eq 1_000_000
159
159
  end
160
-
160
+
161
161
  it 'converts to microliters' do
162
- subject.convert_to(:µl).quantity.should eq 10_000_000
162
+ expect(subject.convert_to(:µl).quantity).to eq 10_000_000
163
163
  end
164
164
  end
165
-
165
+
166
166
  describe 'centiliters' do
167
- subject { Measurement.parse('100000 cl') }
168
-
167
+ subject { described_class.parse('100000 cl') }
168
+
169
169
  it 'converts to kiloliters' do
170
- subject.convert_to(:kl).quantity.should eq 1
170
+ expect(subject.convert_to(:kl).quantity).to eq 1
171
171
  end
172
-
172
+
173
173
  it 'converts to hectoliters' do
174
- subject.convert_to(:hl).quantity.should eq 10
174
+ expect(subject.convert_to(:hl).quantity).to eq 10
175
175
  end
176
-
176
+
177
177
  it 'converts to dekaliters' do
178
- subject.convert_to(:dal).quantity.should eq 100
178
+ expect(subject.convert_to(:dal).quantity).to eq 100
179
179
  end
180
-
180
+
181
181
  it 'converts to liters' do
182
- subject.convert_to(:l).quantity.should eq 1_000
182
+ expect(subject.convert_to(:l).quantity).to eq 1_000
183
183
  end
184
-
184
+
185
185
  it 'converts to deciliters' do
186
- subject.convert_to(:dl).quantity.should eq 10_000
186
+ expect(subject.convert_to(:dl).quantity).to eq 10_000
187
187
  end
188
-
188
+
189
189
  it 'converts to milliliters' do
190
- subject.convert_to(:ml).quantity.should eq 1_000_000
190
+ expect(subject.convert_to(:ml).quantity).to eq 1_000_000
191
191
  end
192
-
192
+
193
193
  it 'converts to microliters' do
194
- subject.convert_to(:µl).quantity.should eq 10_000_000
194
+ expect(subject.convert_to(:µl).quantity).to eq 10_000_000
195
195
  end
196
196
  end
197
-
197
+
198
198
  describe 'milliliters' do
199
- subject { Measurement.parse('1000000 ml') }
200
-
199
+ subject { described_class.parse('1000000 ml') }
200
+
201
201
  it 'converts to kiloliters' do
202
- subject.convert_to(:kl).quantity.should eq 1
202
+ expect(subject.convert_to(:kl).quantity).to eq 1
203
203
  end
204
-
204
+
205
205
  it 'converts to hectoliters' do
206
- subject.convert_to(:hl).quantity.should eq 10
206
+ expect(subject.convert_to(:hl).quantity).to eq 10
207
207
  end
208
-
208
+
209
209
  it 'converts to dekaliters' do
210
- subject.convert_to(:dal).quantity.should eq 100
210
+ expect(subject.convert_to(:dal).quantity).to eq 100
211
211
  end
212
-
212
+
213
213
  it 'converts to liters' do
214
- subject.convert_to(:l).quantity.should eq 1_000
214
+ expect(subject.convert_to(:l).quantity).to eq 1_000
215
215
  end
216
-
216
+
217
217
  it 'converts to deciliters' do
218
- subject.convert_to(:dl).quantity.should eq 10_000
218
+ expect(subject.convert_to(:dl).quantity).to eq 10_000
219
219
  end
220
-
220
+
221
221
  it 'converts to centiliters' do
222
- subject.convert_to(:cl).quantity.should eq 100_000
222
+ expect(subject.convert_to(:cl).quantity).to eq 100_000
223
223
  end
224
-
224
+
225
225
  it 'converts to microliters' do
226
- subject.convert_to(:µl).quantity.should eq 10_000_000
226
+ expect(subject.convert_to(:µl).quantity).to eq 10_000_000
227
227
  end
228
228
  end
229
-
229
+
230
230
  describe 'microliters' do
231
- subject { Measurement.parse('10000000 µl') }
232
-
231
+ subject { described_class.parse('10000000 µl') }
232
+
233
233
  it 'converts to kiloliters' do
234
- subject.convert_to(:kl).quantity.should eq 1
234
+ expect(subject.convert_to(:kl).quantity).to eq 1
235
235
  end
236
-
236
+
237
237
  it 'converts to hectoliters' do
238
- subject.convert_to(:hl).quantity.should eq 10
238
+ expect(subject.convert_to(:hl).quantity).to eq 10
239
239
  end
240
-
240
+
241
241
  it 'converts to dekaliters' do
242
- subject.convert_to(:dal).quantity.should eq 100
242
+ expect(subject.convert_to(:dal).quantity).to eq 100
243
243
  end
244
-
244
+
245
245
  it 'converts to liters' do
246
- subject.convert_to(:l).quantity.should eq 1_000
246
+ expect(subject.convert_to(:l).quantity).to eq 1_000
247
247
  end
248
-
248
+
249
249
  it 'converts to deciliters' do
250
- subject.convert_to(:dl).quantity.should eq 10_000
250
+ expect(subject.convert_to(:dl).quantity).to eq 10_000
251
251
  end
252
-
252
+
253
253
  it 'converts to centiliters' do
254
- subject.convert_to(:cl).quantity.should eq 100_000
254
+ expect(subject.convert_to(:cl).quantity).to eq 100_000
255
255
  end
256
-
256
+
257
257
  it 'converts to milliliters' do
258
- subject.convert_to(:ml).quantity.should eq 1_000_000
258
+ expect(subject.convert_to(:ml).quantity).to eq 1_000_000
259
259
  end
260
260
  end
261
261
  end
@@ -2,324 +2,324 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Measurement do
5
+ RSpec.describe Measurement do
6
6
  describe 'tonnes' do
7
- subject { Measurement.parse('0.001 tonne') }
8
-
7
+ subject { described_class.parse('0.001 tonne') }
8
+
9
9
  it 'converts to hectograms' do
10
- subject.convert_to(:hg).quantity.should eq 10
10
+ expect(subject.convert_to(:hg).quantity).to eq 10
11
11
  end
12
-
12
+
13
13
  it 'converts to dekagrams' do
14
- subject.convert_to(:dag).quantity.should eq 100
14
+ expect(subject.convert_to(:dag).quantity).to eq 100
15
15
  end
16
-
16
+
17
17
  it 'converts to grams' do
18
- subject.convert_to(:g).quantity.should eq 1_000
18
+ expect(subject.convert_to(:g).quantity).to eq 1_000
19
19
  end
20
-
20
+
21
21
  it 'converts to decigrams' do
22
- subject.convert_to(:dg).quantity.should eq 10_000
22
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
23
23
  end
24
-
24
+
25
25
  it 'converts to centigrams' do
26
- subject.convert_to(:cg).quantity.should eq 100_000
26
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
27
27
  end
28
-
28
+
29
29
  it 'converts to milligrams' do
30
- subject.convert_to(:mg).quantity.should eq 1_000_000
30
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
31
31
  end
32
-
32
+
33
33
  it 'converts to micrograms' do
34
- subject.convert_to(:µg).quantity.should eq 10_000_000
34
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
35
35
  end
36
36
  end
37
-
37
+
38
38
  describe 'kilograms' do
39
- subject { Measurement.parse('1 kg') }
40
-
39
+ subject { described_class.parse('1 kg') }
40
+
41
41
  it 'converts to tonnes' do
42
- subject.convert_to(:t).quantity.should eq 0.001
42
+ expect(subject.convert_to(:t).quantity).to eq 0.001
43
43
  end
44
-
44
+
45
45
  it 'converts to hectograms' do
46
- subject.convert_to(:hg).quantity.should eq 10
46
+ expect(subject.convert_to(:hg).quantity).to eq 10
47
47
  end
48
-
48
+
49
49
  it 'converts to dekagrams' do
50
- subject.convert_to(:dag).quantity.should eq 100
50
+ expect(subject.convert_to(:dag).quantity).to eq 100
51
51
  end
52
-
52
+
53
53
  it 'converts to grams' do
54
- subject.convert_to(:g).quantity.should eq 1_000
54
+ expect(subject.convert_to(:g).quantity).to eq 1_000
55
55
  end
56
-
56
+
57
57
  it 'converts to decigrams' do
58
- subject.convert_to(:dg).quantity.should eq 10_000
58
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
59
59
  end
60
-
60
+
61
61
  it 'converts to centigrams' do
62
- subject.convert_to(:cg).quantity.should eq 100_000
62
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
63
63
  end
64
-
64
+
65
65
  it 'converts to milligrams' do
66
- subject.convert_to(:mg).quantity.should eq 1_000_000
66
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
67
67
  end
68
-
68
+
69
69
  it 'converts to micrograms' do
70
- subject.convert_to(:µg).quantity.should eq 10_000_000
70
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
71
71
  end
72
72
  end
73
-
73
+
74
74
  describe 'hectograms' do
75
- subject { Measurement.parse('10 hg') }
76
-
75
+ subject { described_class.parse('10 hg') }
76
+
77
77
  it 'converts to tonnes' do
78
- subject.convert_to(:t).quantity.should eq 0.001
78
+ expect(subject.convert_to(:t).quantity).to eq 0.001
79
79
  end
80
-
80
+
81
81
  it 'converts to kilograms' do
82
- subject.convert_to(:kg).quantity.should eq 1
82
+ expect(subject.convert_to(:kg).quantity).to eq 1
83
83
  end
84
-
84
+
85
85
  it 'converts to dekagrams' do
86
- subject.convert_to(:dag).quantity.should eq 100
86
+ expect(subject.convert_to(:dag).quantity).to eq 100
87
87
  end
88
-
88
+
89
89
  it 'converts to grams' do
90
- subject.convert_to(:g).quantity.should eq 1_000
90
+ expect(subject.convert_to(:g).quantity).to eq 1_000
91
91
  end
92
-
92
+
93
93
  it 'converts to decigrams' do
94
- subject.convert_to(:dg).quantity.should eq 10_000
94
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
95
95
  end
96
-
96
+
97
97
  it 'converts to centigrams' do
98
- subject.convert_to(:cg).quantity.should eq 100_000
98
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
99
99
  end
100
-
100
+
101
101
  it 'converts to milligrams' do
102
- subject.convert_to(:mg).quantity.should eq 1_000_000
102
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
103
103
  end
104
-
104
+
105
105
  it 'converts to micrograms' do
106
- subject.convert_to(:µg).quantity.should eq 10_000_000
106
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
107
107
  end
108
108
  end
109
-
109
+
110
110
  describe 'dekagrams' do
111
- subject { Measurement.parse('100 dag') }
112
-
111
+ subject { described_class.parse('100 dag') }
112
+
113
113
  it 'converts to tonnes' do
114
- subject.convert_to(:t).quantity.should eq 0.001
114
+ expect(subject.convert_to(:t).quantity).to eq 0.001
115
115
  end
116
-
116
+
117
117
  it 'converts to kilograms' do
118
- subject.convert_to(:kg).quantity.should eq 1
118
+ expect(subject.convert_to(:kg).quantity).to eq 1
119
119
  end
120
-
120
+
121
121
  it 'converts to hectograms' do
122
- subject.convert_to(:hg).quantity.should eq 10
122
+ expect(subject.convert_to(:hg).quantity).to eq 10
123
123
  end
124
-
124
+
125
125
  it 'converts to grams' do
126
- subject.convert_to(:g).quantity.should eq 1_000
126
+ expect(subject.convert_to(:g).quantity).to eq 1_000
127
127
  end
128
-
128
+
129
129
  it 'converts to decigrams' do
130
- subject.convert_to(:dg).quantity.should eq 10_000
130
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
131
131
  end
132
-
132
+
133
133
  it 'converts to centigrams' do
134
- subject.convert_to(:cg).quantity.should eq 100_000
134
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
135
135
  end
136
-
136
+
137
137
  it 'converts to milligrams' do
138
- subject.convert_to(:mg).quantity.should eq 1_000_000
138
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
139
139
  end
140
-
140
+
141
141
  it 'converts to micrograms' do
142
- subject.convert_to(:µg).quantity.should eq 10_000_000
142
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
143
143
  end
144
144
  end
145
-
145
+
146
146
  describe 'grams' do
147
- subject { Measurement.parse('1000 g') }
148
-
147
+ subject { described_class.parse('1000 g') }
148
+
149
149
  it 'converts to tonnes' do
150
- subject.convert_to(:t).quantity.should eq 0.001
150
+ expect(subject.convert_to(:t).quantity).to eq 0.001
151
151
  end
152
-
152
+
153
153
  it 'converts to kilograms' do
154
- subject.convert_to(:kg).quantity.should eq 1
154
+ expect(subject.convert_to(:kg).quantity).to eq 1
155
155
  end
156
-
156
+
157
157
  it 'converts to hectograms' do
158
- subject.convert_to(:hg).quantity.should eq 10
158
+ expect(subject.convert_to(:hg).quantity).to eq 10
159
159
  end
160
-
160
+
161
161
  it 'converts to dekagrams' do
162
- subject.convert_to(:dag).quantity.should eq 100
162
+ expect(subject.convert_to(:dag).quantity).to eq 100
163
163
  end
164
-
164
+
165
165
  it 'converts to decigrams' do
166
- subject.convert_to(:dg).quantity.should eq 10_000
166
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
167
167
  end
168
-
168
+
169
169
  it 'converts to centigrams' do
170
- subject.convert_to(:cg).quantity.should eq 100_000
170
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
171
171
  end
172
-
172
+
173
173
  it 'converts to milligrams' do
174
- subject.convert_to(:mg).quantity.should eq 1_000_000
174
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
175
175
  end
176
-
176
+
177
177
  it 'converts to micrograms' do
178
- subject.convert_to(:µg).quantity.should eq 10_000_000
178
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
179
179
  end
180
180
  end
181
-
181
+
182
182
  describe 'decigrams' do
183
- subject { Measurement.parse('10000 dg') }
184
-
183
+ subject { described_class.parse('10000 dg') }
184
+
185
185
  it 'converts to tonnes' do
186
- subject.convert_to(:t).quantity.should eq 0.001
186
+ expect(subject.convert_to(:t).quantity).to eq 0.001
187
187
  end
188
-
188
+
189
189
  it 'converts to kilograms' do
190
- subject.convert_to(:kg).quantity.should eq 1
190
+ expect(subject.convert_to(:kg).quantity).to eq 1
191
191
  end
192
-
192
+
193
193
  it 'converts to hectograms' do
194
- subject.convert_to(:hg).quantity.should eq 10
194
+ expect(subject.convert_to(:hg).quantity).to eq 10
195
195
  end
196
-
196
+
197
197
  it 'converts to dekagrams' do
198
- subject.convert_to(:dag).quantity.should eq 100
198
+ expect(subject.convert_to(:dag).quantity).to eq 100
199
199
  end
200
-
200
+
201
201
  it 'converts to grams' do
202
- subject.convert_to(:g).quantity.should eq 1_000
202
+ expect(subject.convert_to(:g).quantity).to eq 1_000
203
203
  end
204
-
204
+
205
205
  it 'converts to centigrams' do
206
- subject.convert_to(:cg).quantity.should eq 100_000
206
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
207
207
  end
208
-
208
+
209
209
  it 'converts to milligrams' do
210
- subject.convert_to(:mg).quantity.should eq 1_000_000
210
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
211
211
  end
212
-
212
+
213
213
  it 'converts to micrograms' do
214
- subject.convert_to(:µg).quantity.should eq 10_000_000
214
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
215
215
  end
216
216
  end
217
-
217
+
218
218
  describe 'centigrams' do
219
- subject { Measurement.parse('100000 cg') }
220
-
219
+ subject { described_class.parse('100000 cg') }
220
+
221
221
  it 'converts to tonnes' do
222
- subject.convert_to(:t).quantity.should eq 0.001
222
+ expect(subject.convert_to(:t).quantity).to eq 0.001
223
223
  end
224
-
224
+
225
225
  it 'converts to kilograms' do
226
- subject.convert_to(:kg).quantity.should eq 1
226
+ expect(subject.convert_to(:kg).quantity).to eq 1
227
227
  end
228
-
228
+
229
229
  it 'converts to hectograms' do
230
- subject.convert_to(:hg).quantity.should eq 10
230
+ expect(subject.convert_to(:hg).quantity).to eq 10
231
231
  end
232
-
232
+
233
233
  it 'converts to dekagrams' do
234
- subject.convert_to(:dag).quantity.should eq 100
234
+ expect(subject.convert_to(:dag).quantity).to eq 100
235
235
  end
236
-
236
+
237
237
  it 'converts to grams' do
238
- subject.convert_to(:g).quantity.should eq 1_000
238
+ expect(subject.convert_to(:g).quantity).to eq 1_000
239
239
  end
240
-
240
+
241
241
  it 'converts to decigrams' do
242
- subject.convert_to(:dg).quantity.should eq 10_000
242
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
243
243
  end
244
-
244
+
245
245
  it 'converts to milligrams' do
246
- subject.convert_to(:mg).quantity.should eq 1_000_000
246
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
247
247
  end
248
-
248
+
249
249
  it 'converts to micrograms' do
250
- subject.convert_to(:µg).quantity.should eq 10_000_000
250
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
251
251
  end
252
252
  end
253
-
253
+
254
254
  describe 'milligrams' do
255
- subject { Measurement.parse('1000000 mg') }
256
-
255
+ subject { described_class.parse('1000000 mg') }
256
+
257
257
  it 'converts to tonnes' do
258
- subject.convert_to(:t).quantity.should eq 0.001
258
+ expect(subject.convert_to(:t).quantity).to eq 0.001
259
259
  end
260
-
260
+
261
261
  it 'converts to kilograms' do
262
- subject.convert_to(:kg).quantity.should eq 1
262
+ expect(subject.convert_to(:kg).quantity).to eq 1
263
263
  end
264
-
264
+
265
265
  it 'converts to hectograms' do
266
- subject.convert_to(:hg).quantity.should eq 10
266
+ expect(subject.convert_to(:hg).quantity).to eq 10
267
267
  end
268
-
268
+
269
269
  it 'converts to dekagrams' do
270
- subject.convert_to(:dag).quantity.should eq 100
270
+ expect(subject.convert_to(:dag).quantity).to eq 100
271
271
  end
272
-
272
+
273
273
  it 'converts to grams' do
274
- subject.convert_to(:g).quantity.should eq 1_000
274
+ expect(subject.convert_to(:g).quantity).to eq 1_000
275
275
  end
276
-
276
+
277
277
  it 'converts to decigrams' do
278
- subject.convert_to(:dg).quantity.should eq 10_000
278
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
279
279
  end
280
-
280
+
281
281
  it 'converts to centigrams' do
282
- subject.convert_to(:cg).quantity.should eq 100_000
282
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
283
283
  end
284
-
284
+
285
285
  it 'converts to micrograms' do
286
- subject.convert_to(:µg).quantity.should eq 10_000_000
286
+ expect(subject.convert_to(:µg).quantity).to eq 10_000_000
287
287
  end
288
288
  end
289
-
289
+
290
290
  describe 'micrograms' do
291
- subject { Measurement.parse('10000000 µg') }
292
-
291
+ subject { described_class.parse('10000000 µg') }
292
+
293
293
  it 'converts to tonnes' do
294
- subject.convert_to(:t).quantity.should eq 0.001
294
+ expect(subject.convert_to(:t).quantity).to eq 0.001
295
295
  end
296
-
296
+
297
297
  it 'converts to kilograms' do
298
- subject.convert_to(:kg).quantity.should eq 1
298
+ expect(subject.convert_to(:kg).quantity).to eq 1
299
299
  end
300
-
300
+
301
301
  it 'converts to hectograms' do
302
- subject.convert_to(:hg).quantity.should eq 10
302
+ expect(subject.convert_to(:hg).quantity).to eq 10
303
303
  end
304
-
304
+
305
305
  it 'converts to dekagrams' do
306
- subject.convert_to(:dag).quantity.should eq 100
306
+ expect(subject.convert_to(:dag).quantity).to eq 100
307
307
  end
308
-
308
+
309
309
  it 'converts to grams' do
310
- subject.convert_to(:g).quantity.should eq 1_000
310
+ expect(subject.convert_to(:g).quantity).to eq 1_000
311
311
  end
312
-
312
+
313
313
  it 'converts to decigrams' do
314
- subject.convert_to(:dg).quantity.should eq 10_000
314
+ expect(subject.convert_to(:dg).quantity).to eq 10_000
315
315
  end
316
-
316
+
317
317
  it 'converts to centigrams' do
318
- subject.convert_to(:cg).quantity.should eq 100_000
318
+ expect(subject.convert_to(:cg).quantity).to eq 100_000
319
319
  end
320
-
320
+
321
321
  it 'converts to milligrams' do
322
- subject.convert_to(:mg).quantity.should eq 1_000_000
322
+ expect(subject.convert_to(:mg).quantity).to eq 1_000_000
323
323
  end
324
324
  end
325
325
  end