phys-units 0.9.7 → 0.9.8

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.
data/spec/unit_spec.rb CHANGED
@@ -4,226 +4,226 @@ require "helper"
4
4
  describe "Create Units" do
5
5
 
6
6
  describe U[1] do
7
- it {should be_an_instance_of Phys::Unit}
8
- its(:factor) {should == 1}
9
- its(:conversion_factor) {should == 1}
10
- its(:name) {should be_nil}
11
- its(:expr) {should be_nil}
12
- its(:offset) {should be_nil}
13
- its(:dimension) {should == {}}
14
- its(:dimension_value) {should == 1}
15
- its(:string_form) {should == ""}
16
- it {should be_dimensionless}
17
- it {should be_scalar}
18
- it {should be_operable}
7
+ it {is_expected.to be_an_instance_of Phys::Unit}
8
+ its(:factor) {is_expected.to eq 1}
9
+ its(:conversion_factor) {is_expected.to eq 1}
10
+ its(:name) {is_expected.to be_nil}
11
+ its(:expr) {is_expected.to be_nil}
12
+ its(:offset) {is_expected.to be_nil}
13
+ its(:dimension) {is_expected.to eq({})}
14
+ its(:dimension_value) {is_expected.to eq 1}
15
+ its(:string_form) {is_expected.to eq ""}
16
+ it {is_expected.to be_dimensionless}
17
+ it {is_expected.to be_scalar}
18
+ it {is_expected.to be_operable}
19
19
  end
20
20
 
21
21
  describe U[2] do
22
- it {should be_an_instance_of Phys::Unit}
23
- its(:factor) {should == 2}
24
- its(:conversion_factor) {should == 2}
25
- its(:name) {should be_nil}
26
- its(:expr) {should be_nil}
27
- its(:offset) {should be_nil}
28
- its(:dimension) {should == {}}
29
- its(:dimension_value) {should == 1}
30
- its(:string_form) {should == "2"}
31
- it {should be_dimensionless}
32
- it {should_not be_scalar}
33
- it {should be_operable}
22
+ it {is_expected.to be_an_instance_of Phys::Unit}
23
+ its(:factor) {is_expected.to eq 2}
24
+ its(:conversion_factor) {is_expected.to eq 2}
25
+ its(:name) {is_expected.to be_nil}
26
+ its(:expr) {is_expected.to be_nil}
27
+ its(:offset) {is_expected.to be_nil}
28
+ its(:dimension) {is_expected.to eq({})}
29
+ its(:dimension_value) {is_expected.to eq 1}
30
+ its(:string_form) {is_expected.to eq "2"}
31
+ it {is_expected.to be_dimensionless}
32
+ it {is_expected.not_to be_scalar}
33
+ it {is_expected.to be_operable}
34
34
  end
35
35
 
36
36
  describe U['pi'] do
37
- it {should be_an_kind_of Phys::Unit}
38
- its(:factor) {should == 1}
39
- its(:conversion_factor) {should == Math::PI}
40
- its(:name) {should == 'pi'}
41
- its(:expr) {should == '!dimensionless'}
42
- its(:offset) {should be_nil}
43
- its(:dimension) {should == {'pi'=>1}}
44
- its(:dimension_value) {should == Math::PI}
45
- its(:string_form) {should == "pi"}
46
- it {should be_dimensionless}
47
- it {should_not be_scalar}
48
- it {should be_operable}
37
+ it {is_expected.to be_an_kind_of Phys::Unit}
38
+ its(:factor) {is_expected.to eq 1}
39
+ its(:conversion_factor) {is_expected.to eq Math::PI}
40
+ its(:name) {is_expected.to eq 'pi'}
41
+ its(:expr) {is_expected.to eq '!dimensionless'}
42
+ its(:offset) {is_expected.to be_nil}
43
+ its(:dimension) {is_expected.to eq({'pi'=>1})}
44
+ its(:dimension_value) {is_expected.to eq Math::PI}
45
+ its(:string_form) {is_expected.to eq "pi"}
46
+ it {is_expected.to be_dimensionless}
47
+ it {is_expected.not_to be_scalar}
48
+ it {is_expected.to be_operable}
49
49
  end
50
50
 
51
51
  describe U['m'] do
52
- it {should be_an_kind_of Phys::Unit}
53
- its(:factor) {should == 1}
54
- its(:conversion_factor) {should == 1}
55
- its(:name) {should == 'm'}
56
- its(:expr) {should == '!'}
57
- its(:offset) {should be_nil}
58
- its(:dimension) {should == {'m'=>1}}
59
- its(:dimension_value) {should == 1}
60
- its(:string_form) {should == "m"}
61
- it {should_not be_dimensionless}
62
- it {should_not be_scalar}
63
- it {should be_operable}
52
+ it {is_expected.to be_an_kind_of Phys::Unit}
53
+ its(:factor) {is_expected.to eq 1}
54
+ its(:conversion_factor) {is_expected.to eq 1}
55
+ its(:name) {is_expected.to eq 'm'}
56
+ its(:expr) {is_expected.to eq '!'}
57
+ its(:offset) {is_expected.to be_nil}
58
+ its(:dimension) {is_expected.to eq({'m'=>1})}
59
+ its(:dimension_value) {is_expected.to eq 1}
60
+ its(:string_form) {is_expected.to eq "m"}
61
+ it {is_expected.not_to be_dimensionless}
62
+ it {is_expected.not_to be_scalar}
63
+ it {is_expected.to be_operable}
64
64
  end
65
65
 
66
66
  describe U[:m] do
67
- it {should == U["m"]}
67
+ it {is_expected.to eq U["m"]}
68
68
  end
69
69
 
70
70
  describe U['miles'] do
71
- it {should be_an_kind_of Phys::Unit}
72
- its(:factor) {should == 1609.344}
73
- its(:factor) {should be_an_instance_of Rational}
74
- its(:conversion_factor) {should == 1609.344}
75
- its(:name) {should == 'mile'}
76
- its(:expr) {should == "5280 ft"}
77
- its(:offset) {should be_nil}
78
- its(:dimension) {should == {'m'=>1}}
79
- its(:dimension_value) {should == 1}
80
- its(:string_form) {should == "1609.344 m"}
81
- it {should_not be_dimensionless}
82
- it {should_not be_scalar}
83
- it {should be_operable}
71
+ it {is_expected.to be_an_kind_of Phys::Unit}
72
+ its(:factor) {is_expected.to eq 1609.344}
73
+ its(:factor) {is_expected.to be_an_instance_of Rational}
74
+ its(:conversion_factor) {is_expected.to eq 1609.344}
75
+ its(:name) {is_expected.to eq 'mile'}
76
+ its(:expr) {is_expected.to eq "5280 ft"}
77
+ its(:offset) {is_expected.to be_nil}
78
+ its(:dimension) {is_expected.to eq({'m'=>1})}
79
+ its(:dimension_value) {is_expected.to eq 1}
80
+ its(:string_form) {is_expected.to eq "1609.344 m"}
81
+ it {is_expected.not_to be_dimensionless}
82
+ it {is_expected.not_to be_scalar}
83
+ it {is_expected.to be_operable}
84
84
  end
85
85
 
86
86
  describe 1.609344*U['km'] do
87
- it {should be_an_kind_of Phys::Unit}
88
- it {should == Phys::Unit[:miles]}
89
- its(:factor) {should == 1609.344}
90
- its(:conversion_factor) {should == 1609.344}
91
- its(:name) {should be_nil}
92
- its(:expr) {should be_nil}
93
- its(:offset) {should be_nil}
94
- its(:dimension) {should == {'m'=>1}}
95
- its(:dimension_value) {should == 1}
96
- its(:string_form) {should == "1609.344 m"}
97
- it {should_not be_dimensionless}
98
- it {should_not be_scalar}
99
- it {should be_operable}
87
+ it {is_expected.to be_an_kind_of Phys::Unit}
88
+ it {is_expected.to eq Phys::Unit[:miles]}
89
+ its(:factor) {is_expected.to eq 1609.344}
90
+ its(:conversion_factor) {is_expected.to eq 1609.344}
91
+ its(:name) {is_expected.to be_nil}
92
+ its(:expr) {is_expected.to be_nil}
93
+ its(:offset) {is_expected.to be_nil}
94
+ its(:dimension) {is_expected.to eq({'m'=>1})}
95
+ its(:dimension_value) {is_expected.to eq 1}
96
+ its(:string_form) {is_expected.to eq "1609.344 m"}
97
+ it {is_expected.not_to be_dimensionless}
98
+ it {is_expected.not_to be_scalar}
99
+ it {is_expected.to be_operable}
100
100
  end
101
101
 
102
102
  describe U['g'] do
103
- it {should be_an_instance_of Phys::Unit}
104
- its(:factor) {should == Rational(1,1000)}
105
- its(:conversion_factor) {should == Rational(1,1000)}
106
- its(:name) {should == 'g'}
107
- #its(:expr) {should == 'gram'}
108
- its(:offset) {should be_nil}
109
- its(:dimension) {should == {'kg'=>1}}
110
- its(:dimension_value) {should == 1}
111
- its(:string_form) {should == "0.001 kg"}
112
- it {should_not be_dimensionless}
113
- it {should_not be_scalar}
114
- it {should be_operable}
103
+ it {is_expected.to be_an_instance_of Phys::Unit}
104
+ its(:factor) {is_expected.to eq Rational(1,1000)}
105
+ its(:conversion_factor) {is_expected.to eq Rational(1,1000)}
106
+ its(:name) {is_expected.to eq 'g'}
107
+ #its(:expr) {is_expected.to eq 'gram'}
108
+ its(:offset) {is_expected.to be_nil}
109
+ its(:dimension) {is_expected.to eq({'kg'=>1})}
110
+ its(:dimension_value) {is_expected.to eq 1}
111
+ its(:string_form) {is_expected.to eq "0.001 kg"}
112
+ it {is_expected.not_to be_dimensionless}
113
+ it {is_expected.not_to be_scalar}
114
+ it {is_expected.to be_operable}
115
115
  end
116
116
 
117
117
 
118
118
  describe U['h'] do
119
- it {should be_an_instance_of Phys::Unit}
120
- its(:factor) {should be_within(1e-16*1e-33).of 6.626069574766962e-34}
121
- its(:conversion_factor) {should be_within(1e-16*1e-33).of 6.626069574766962e-34}
122
- its(:name) {should == 'h'}
123
- its(:expr) {should == "4.135667516e-15 eV s"}
124
- its(:offset) {should be_nil}
125
- its(:dimension) {should == {'kg'=>1,'m'=>2,'s'=>-1}}
126
- its(:dimension_value) {should == 1}
127
- its(:string_form) {should == "6.626069574766962e-34 s^-1 kg m^2"}
128
- it {should_not be_dimensionless}
129
- it {should_not be_scalar}
130
- it {should be_operable}
119
+ it {is_expected.to be_an_instance_of Phys::Unit}
120
+ its(:factor) {is_expected.to be_within(1e-16*1e-33).of 6.626069574766962e-34}
121
+ its(:conversion_factor) {is_expected.to be_within(1e-16*1e-33).of 6.626069574766962e-34}
122
+ its(:name) {is_expected.to eq 'h'}
123
+ its(:expr) {is_expected.to eq "4.135667516e-15 eV s"}
124
+ its(:offset) {is_expected.to be_nil}
125
+ its(:dimension) {is_expected.to eq({'kg'=>1,'m'=>2,'s'=>-1})}
126
+ its(:dimension_value) {is_expected.to eq 1}
127
+ its(:string_form) {is_expected.to eq "6.626069574766962e-34 s^-1 kg m^2"}
128
+ it {is_expected.not_to be_dimensionless}
129
+ it {is_expected.not_to be_scalar}
130
+ it {is_expected.to be_operable}
131
131
  end
132
132
 
133
133
  describe U['e'] do
134
- it {should be_an_instance_of Phys::Unit}
135
- its(:factor) {should be_within(1e-15*1e-18).of 1.602176565e-19}
136
- its(:conversion_factor) {should be_within(1e-15*1e-18).of 1.602176565e-19}
137
- its(:name) {should == 'e'}
138
- its(:expr) {should == "1.602176565e-19 C"}
139
- its(:offset) {should be_nil}
140
- its(:dimension) {should == {'A'=>1,'s'=>1}}
141
- its(:dimension_value) {should == 1}
142
- its(:string_form) {should == "1.602176565e-19 A s"}
143
- it {should_not be_dimensionless}
144
- it {should_not be_scalar}
145
- it {should be_operable}
134
+ it {is_expected.to be_an_instance_of Phys::Unit}
135
+ its(:factor) {is_expected.to be_within(1e-15*1e-18).of 1.602176565e-19}
136
+ its(:conversion_factor) {is_expected.to be_within(1e-15*1e-18).of 1.602176565e-19}
137
+ its(:name) {is_expected.to eq 'e'}
138
+ its(:expr) {is_expected.to eq "1.602176565e-19 C"}
139
+ its(:offset) {is_expected.to be_nil}
140
+ its(:dimension) {is_expected.to eq({'A'=>1,'s'=>1})}
141
+ its(:dimension_value) {is_expected.to eq 1}
142
+ its(:string_form) {is_expected.to eq "1.602176565e-19 A s"}
143
+ it {is_expected.not_to be_dimensionless}
144
+ it {is_expected.not_to be_scalar}
145
+ it {is_expected.to be_operable}
146
146
  end
147
147
 
148
148
  describe U.parse('123.5 s') do
149
- it {should be_an_instance_of Phys::Unit}
150
- its(:factor) {should == 123.5}
151
- its(:conversion_factor) {should == 123.5}
152
- its(:name) {should be_nil}
153
- its(:expr) {should be_nil}
154
- its(:offset) {should be_nil}
155
- its(:dimension) {should == {'s'=>1}}
156
- its(:dimension_value) {should == 1}
157
- its(:string_form) {should == "123.5 s"}
158
- it {should_not be_dimensionless}
159
- it {should_not be_scalar}
160
- it {should be_operable}
149
+ it {is_expected.to be_an_instance_of Phys::Unit}
150
+ its(:factor) {is_expected.to eq 123.5}
151
+ its(:conversion_factor) {is_expected.to eq 123.5}
152
+ its(:name) {is_expected.to be_nil}
153
+ its(:expr) {is_expected.to be_nil}
154
+ its(:offset) {is_expected.to be_nil}
155
+ its(:dimension) {is_expected.to eq({'s'=>1})}
156
+ its(:dimension_value) {is_expected.to eq 1}
157
+ its(:string_form) {is_expected.to eq "123.5 s"}
158
+ it {is_expected.not_to be_dimensionless}
159
+ it {is_expected.not_to be_scalar}
160
+ it {is_expected.to be_operable}
161
161
  end
162
162
 
163
163
  describe U['m']/U['s'] do
164
- it {should be_an_instance_of Phys::Unit}
165
- its(:factor) {should == 1}
166
- its(:conversion_factor) {should == 1}
167
- its(:name) {should be_nil}
168
- its(:expr) {should be_nil}
169
- its(:offset) {should be_nil}
170
- its(:dimension) {should == {'m'=>1, 's'=>-1}}
171
- its(:dimension_value) {should == 1}
172
- its(:string_form) {should == "m s^-1"}
173
- it {should_not be_dimensionless}
174
- it {should_not be_scalar}
175
- it {should be_operable}
176
- it {should === Q[1,'miles/hr']}
164
+ it {is_expected.to be_an_instance_of Phys::Unit}
165
+ its(:factor) {is_expected.to eq 1}
166
+ its(:conversion_factor) {is_expected.to eq 1}
167
+ its(:name) {is_expected.to be_nil}
168
+ its(:expr) {is_expected.to be_nil}
169
+ its(:offset) {is_expected.to be_nil}
170
+ its(:dimension) {is_expected.to eq({'m'=>1, 's'=>-1})}
171
+ its(:dimension_value) {is_expected.to eq 1}
172
+ its(:string_form) {is_expected.to eq "m s^-1"}
173
+ it {is_expected.not_to be_dimensionless}
174
+ it {is_expected.not_to be_scalar}
175
+ it {is_expected.to be_operable}
176
+ it {is_expected.to be_comformable_with Q[1,'miles/hr']}
177
177
  end
178
178
 
179
179
  describe U.parse('(m/s)**2') do
180
- it {should be_an_instance_of Phys::Unit}
181
- its(:factor) {should == 1}
182
- its(:conversion_factor) {should == 1}
183
- its(:name) {should be_nil}
184
- its(:expr) {should be_nil}
185
- its(:offset) {should be_nil}
186
- its(:dimension) {should == {'m'=>2, 's'=>-2}}
187
- its(:dimension_value) {should == 1}
188
- its(:string_form) {should == "m^2 s^-2"}
189
- it {should_not be_dimensionless}
190
- it {should_not be_scalar}
191
- it {should be_operable}
180
+ it {is_expected.to be_an_instance_of Phys::Unit}
181
+ its(:factor) {is_expected.to eq 1}
182
+ its(:conversion_factor) {is_expected.to eq 1}
183
+ its(:name) {is_expected.to be_nil}
184
+ its(:expr) {is_expected.to be_nil}
185
+ its(:offset) {is_expected.to be_nil}
186
+ its(:dimension) {is_expected.to eq({'m'=>2, 's'=>-2})}
187
+ its(:dimension_value) {is_expected.to eq 1}
188
+ its(:string_form) {is_expected.to eq "m^2 s^-2"}
189
+ it {is_expected.not_to be_dimensionless}
190
+ it {is_expected.not_to be_scalar}
191
+ it {is_expected.to be_operable}
192
192
  end
193
193
 
194
194
  describe U.parse("3.6 km/hour") do
195
- its(:string_form) {should == "m s^-1"}
195
+ its(:string_form) {is_expected.to eq "m s^-1"}
196
196
  end
197
197
 
198
198
  describe U['tempC'] do
199
- it {should be_an_instance_of Phys::OffsetUnit}
200
- its(:factor) {should == 1}
201
- its(:conversion_factor) {should == 1}
202
- its(:name) {should == 'tempC'}
203
- its(:expr) {should be_nil}
204
- its(:offset) {should == 273.15}
205
- its(:dimension) {should == {'K'=>1}}
206
- its(:dimension_value) {should == 1}
207
- its(:string_form) {should == "K"}
208
- it {should_not be_dimensionless}
209
- it {should_not be_scalar}
210
- it {should_not be_operable}
199
+ it {is_expected.to be_an_instance_of Phys::OffsetUnit}
200
+ its(:factor) {is_expected.to eq 1}
201
+ its(:conversion_factor) {is_expected.to eq 1}
202
+ its(:name) {is_expected.to eq 'tempC'}
203
+ its(:expr) {is_expected.to be_nil}
204
+ its(:offset) {is_expected.to eq 273.15}
205
+ its(:dimension) {is_expected.to eq({'K'=>1})}
206
+ its(:dimension_value) {is_expected.to eq 1}
207
+ its(:string_form) {is_expected.to eq "K"}
208
+ it {is_expected.not_to be_dimensionless}
209
+ it {is_expected.not_to be_scalar}
210
+ it {is_expected.not_to be_operable}
211
211
  end
212
212
 
213
213
  describe U['tempF'] do
214
- it {should be_an_instance_of Phys::OffsetUnit}
215
- its(:factor) {should == Rational(5,9)}
216
- its(:factor) {should be_an_instance_of Rational}
217
- its(:conversion_factor) {should == Rational(5,9)}
218
- its(:name) {should == 'tempF'}
219
- its(:expr) {should be_nil}
220
- its(:offset) {should == Rational(45967,180)}
221
- its(:dimension) {should == {'K'=>1}}
222
- its(:dimension_value) {should == 1}
223
- its(:string_form) {should == "(1/1.8) K"}
224
- it {should_not be_dimensionless}
225
- it {should_not be_scalar}
226
- it {should_not be_operable}
214
+ it {is_expected.to be_an_instance_of Phys::OffsetUnit}
215
+ its(:factor) {is_expected.to eq Rational(5,9)}
216
+ its(:factor) {is_expected.to be_an_instance_of Rational}
217
+ its(:conversion_factor) {is_expected.to eq Rational(5,9)}
218
+ its(:name) {is_expected.to eq 'tempF'}
219
+ its(:expr) {is_expected.to be_nil}
220
+ its(:offset) {is_expected.to eq Rational(45967,180)}
221
+ its(:dimension) {is_expected.to eq({'K'=>1})}
222
+ its(:dimension_value) {is_expected.to eq 1}
223
+ its(:string_form) {is_expected.to eq "(1/1.8) K"}
224
+ it {is_expected.not_to be_dimensionless}
225
+ it {is_expected.not_to be_scalar}
226
+ it {is_expected.not_to be_operable}
227
227
  end
228
228
 
229
229
  describe "temperature unit" do
data/spec/utils_spec.rb CHANGED
@@ -6,11 +6,11 @@ Utils = Phys::Unit::Utils
6
6
  describe "UnitUtils test" do
7
7
 
8
8
  describe Utils.num_inspect(Rational(1609344,1000)) do
9
- it {should == "1609.344"}
9
+ it {is_expected.to eq "1609.344"}
10
10
  end
11
11
 
12
12
  describe Utils.num_inspect(Rational(1000,1609344)) do
13
- it {should == "(1/1609.344)"}
13
+ it {is_expected.to eq "(1/1609.344)"}
14
14
  end
15
15
 
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phys-units
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-27 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.2.0
102
+ rubygems_version: 2.4.5
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Library for Unit conversion of Physical Quantities using GNU Units data.
@@ -111,3 +111,4 @@ test_files:
111
111
  - spec/quantity_spec.rb
112
112
  - spec/unit_spec.rb
113
113
  - spec/utils_spec.rb
114
+ has_rdoc: