aixm 0.3.7 → 0.3.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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +26 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +17 -4
- data/README.md +23 -5
- data/lib/aixm/component/fato.rb +3 -3
- data/lib/aixm/component/frequency.rb +1 -1
- data/lib/aixm/component/geometry/border.rb +9 -3
- data/lib/aixm/component/helipad.rb +1 -1
- data/lib/aixm/component/lighting.rb +1 -1
- data/lib/aixm/component/runway.rb +4 -7
- data/lib/aixm/config.rb +2 -1
- data/lib/aixm/document.rb +1 -0
- data/lib/aixm/feature/address.rb +1 -1
- data/lib/aixm/feature/airport.rb +13 -4
- data/lib/aixm/feature/airspace.rb +11 -8
- data/lib/aixm/feature/navigational_aid/designated_point.rb +1 -1
- data/lib/aixm/feature/navigational_aid/dme.rb +1 -1
- data/lib/aixm/feature/navigational_aid/marker.rb +1 -1
- data/lib/aixm/feature/navigational_aid/ndb.rb +1 -1
- data/lib/aixm/feature/navigational_aid/tacan.rb +1 -1
- data/lib/aixm/feature/navigational_aid/vor.rb +1 -1
- data/lib/aixm/feature/obstacle.rb +1 -1
- data/lib/aixm/feature/obstacle_group.rb +1 -1
- data/lib/aixm/feature/organisation.rb +1 -1
- data/lib/aixm/feature/service.rb +1 -1
- data/lib/aixm/feature/unit.rb +1 -1
- data/lib/aixm/refinements.rb +39 -8
- data/lib/aixm/version.rb +1 -1
- data/rakefile.rb +22 -8
- data/spec/lib/aixm/a_spec.rb +55 -55
- data/spec/lib/aixm/component/fato_spec.rb +30 -23
- data/spec/lib/aixm/component/frequency_spec.rb +12 -13
- data/spec/lib/aixm/component/geometry/arc_spec.rb +7 -9
- data/spec/lib/aixm/component/geometry/border_spec.rb +8 -3
- data/spec/lib/aixm/component/geometry/circle_spec.rb +6 -8
- data/spec/lib/aixm/component/geometry/point_spec.rb +2 -4
- data/spec/lib/aixm/component/geometry_spec.rb +57 -62
- data/spec/lib/aixm/component/helipad_spec.rb +25 -19
- data/spec/lib/aixm/component/layer_spec.rb +17 -19
- data/spec/lib/aixm/component/lighting_spec.rb +21 -15
- data/spec/lib/aixm/component/runway_spec.rb +44 -37
- data/spec/lib/aixm/component/surface_spec.rb +24 -24
- data/spec/lib/aixm/component/timetable_spec.rb +7 -9
- data/spec/lib/aixm/component/vertical_limits_spec.rb +9 -12
- data/spec/lib/aixm/config_spec.rb +8 -8
- data/spec/lib/aixm/d_spec.rb +28 -28
- data/spec/lib/aixm/document_spec.rb +46 -37
- data/spec/lib/aixm/errors_spec.rb +2 -2
- data/spec/lib/aixm/f_spec.rb +16 -16
- data/spec/lib/aixm/feature/address_spec.rb +12 -7
- data/spec/lib/aixm/feature/airport_spec.rb +80 -74
- data/spec/lib/aixm/feature/airspace_spec.rb +32 -28
- data/spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb +16 -11
- data/spec/lib/aixm/feature/navigational_aid/dme_spec.rb +22 -16
- data/spec/lib/aixm/feature/navigational_aid/marker_spec.rb +13 -7
- data/spec/lib/aixm/feature/navigational_aid/ndb_spec.rb +15 -9
- data/spec/lib/aixm/feature/navigational_aid/tacan_spec.rb +22 -16
- data/spec/lib/aixm/feature/navigational_aid/vor_spec.rb +21 -15
- data/spec/lib/aixm/feature/navigational_aid_spec.rb +6 -6
- data/spec/lib/aixm/feature/obstacle_group_spec.rb +25 -21
- data/spec/lib/aixm/feature/obstacle_spec.rb +47 -42
- data/spec/lib/aixm/feature/organisation_spec.rb +16 -10
- data/spec/lib/aixm/feature/service_spec.rb +9 -9
- data/spec/lib/aixm/feature/unit_spec.rb +21 -13
- data/spec/lib/aixm/feature_spec.rb +5 -5
- data/spec/lib/aixm/p_spec.rb +37 -37
- data/spec/lib/aixm/refinements_spec.rb +164 -115
- data/spec/lib/aixm/version_spec.rb +1 -1
- data/spec/lib/aixm/w_spec.rb +28 -28
- data/spec/lib/aixm/xy_spec.rb +34 -34
- data/spec/lib/aixm/z_spec.rb +19 -19
- data/spec/macros/marking.rb +3 -3
- data/spec/macros/organisation.rb +2 -2
- data/spec/macros/remarks.rb +3 -3
- data/spec/macros/timetable.rb +2 -2
- data/spec/macros/xy.rb +2 -2
- data/spec/macros/z_qnh.rb +2 -2
- data/spec/spec_helper.rb +7 -0
- metadata +3 -3
- data/.travis.yml +0 -8
@@ -7,36 +7,36 @@ describe AIXM::Feature::Organisation do
|
|
7
7
|
|
8
8
|
describe :name= do
|
9
9
|
it "fails on invalid values" do
|
10
|
-
[nil, :foobar, 123].wont_be_written_to subject, :name
|
10
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :name
|
11
11
|
end
|
12
12
|
|
13
13
|
it "upcases and transcodes valid values" do
|
14
|
-
subject.tap { |s| s.name = 'Nîmes-Alès' }.name.must_equal 'NIMES-ALES'
|
14
|
+
_(subject.tap { |s| s.name = 'Nîmes-Alès' }.name).must_equal 'NIMES-ALES'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe :type= do
|
19
19
|
it "fails on invalid values" do
|
20
|
-
[nil, :foobar, 123].wont_be_written_to subject, :type
|
20
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :type
|
21
21
|
end
|
22
22
|
|
23
23
|
it "looks up valid values" do
|
24
|
-
subject.tap { |s| s.type = :state }.type.must_equal :state
|
25
|
-
subject.tap { |s| s.type = :IO }.type.must_equal :international_organisation
|
24
|
+
_(subject.tap { |s| s.type = :state }.type).must_equal :state
|
25
|
+
_(subject.tap { |s| s.type = :IO }.type).must_equal :international_organisation
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe :id= do
|
30
30
|
it "fails on invalid values" do
|
31
|
-
[:foobar, 123].wont_be_written_to subject, :id
|
31
|
+
_([:foobar, 123]).wont_be_written_to subject, :id
|
32
32
|
end
|
33
33
|
|
34
34
|
it "accepts nil value" do
|
35
|
-
[nil].must_be_written_to subject, :id
|
35
|
+
_([nil]).must_be_written_to subject, :id
|
36
36
|
end
|
37
37
|
|
38
38
|
it "upcases valid values" do
|
39
|
-
subject.tap { |s| s.id = 'lf' }.id.must_equal 'LF'
|
39
|
+
_(subject.tap { |s| s.id = 'lf' }.id).must_equal 'LF'
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -47,7 +47,7 @@ describe AIXM::Feature::Organisation do
|
|
47
47
|
describe :to_xml do
|
48
48
|
it "builds correct complete OFMX" do
|
49
49
|
AIXM.ofmx!
|
50
|
-
subject.to_xml.must_equal <<~END
|
50
|
+
_(subject.to_xml).must_equal <<~END
|
51
51
|
<!-- Organisation: FRANCE -->
|
52
52
|
<Org source="LF|GEN|0.0 FACTORY|0|0">
|
53
53
|
<OrgUid>
|
@@ -63,7 +63,7 @@ describe AIXM::Feature::Organisation do
|
|
63
63
|
it "builds correct minimal OFMX" do
|
64
64
|
AIXM.ofmx!
|
65
65
|
subject.id = subject.remarks = nil
|
66
|
-
subject.to_xml.must_equal <<~END
|
66
|
+
_(subject.to_xml).must_equal <<~END
|
67
67
|
<!-- Organisation: FRANCE -->
|
68
68
|
<Org source="LF|GEN|0.0 FACTORY|0|0">
|
69
69
|
<OrgUid>
|
@@ -73,5 +73,11 @@ describe AIXM::Feature::Organisation do
|
|
73
73
|
</Org>
|
74
74
|
END
|
75
75
|
end
|
76
|
+
|
77
|
+
it "builds OFMX with mid" do
|
78
|
+
AIXM.ofmx!
|
79
|
+
AIXM.config.mid_region = 'LF'
|
80
|
+
_(subject.to_xml).must_match /<OrgUid mid="b5fef8e2-ea45-7326-6b2f-38cb45cd21a8">/
|
81
|
+
end
|
76
82
|
end
|
77
83
|
end
|
@@ -10,19 +10,19 @@ describe AIXM::Feature::Service do
|
|
10
10
|
subject = AIXM::Feature::Service.new(
|
11
11
|
type: :approach_control_service
|
12
12
|
)
|
13
|
-
subject.frequencies.must_equal []
|
13
|
+
_(subject.frequencies).must_equal []
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe :type= do
|
18
18
|
it "fails on invalid values" do
|
19
|
-
|
20
|
-
|
19
|
+
_{ subject.type = :foobar }.must_raise ArgumentError
|
20
|
+
_{ subject.type = nil }.must_raise ArgumentError
|
21
21
|
end
|
22
22
|
|
23
23
|
it "looks up valid values" do
|
24
|
-
subject.tap { |s| s.type = :area_control_service }.type.must_equal :area_control_service
|
25
|
-
subject.tap { |s| s.type = :ATIS }.type.must_equal :automated_terminal_information_service
|
24
|
+
_(subject.tap { |s| s.type = :area_control_service }.type).must_equal :area_control_service
|
25
|
+
_(subject.tap { |s| s.type = :ATIS }.type).must_equal :automated_terminal_information_service
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -36,23 +36,23 @@ describe AIXM::Feature::Service do
|
|
36
36
|
|
37
37
|
describe :add_frequency do
|
38
38
|
it "fails on invalid arguments" do
|
39
|
-
|
39
|
+
_{ subject.add_frequency nil }.must_raise ArgumentError
|
40
40
|
end
|
41
41
|
|
42
42
|
it "adds frequency to the array" do
|
43
43
|
count = subject.frequencies.count
|
44
44
|
subject.add_frequency(AIXM::Factory.frequency)
|
45
|
-
subject.frequencies.count.must_equal count + 1
|
45
|
+
_(subject.frequencies.count).must_equal count + 1
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe :guess_unit_type do
|
50
50
|
it "finds the probably unit type for a matchable service" do
|
51
|
-
subject.tap { |s| s.type = :flight_information_service }.guessed_unit_type.must_equal :flight_information_centre
|
51
|
+
_(subject.tap { |s| s.type = :flight_information_service }.guessed_unit_type).must_equal :flight_information_centre
|
52
52
|
end
|
53
53
|
|
54
54
|
it "returns nil for an unmatchable service" do
|
55
|
-
subject.tap { |s| s.type = :aeronautical_mobile_satellite_service }.guessed_unit_type.must_be_nil
|
55
|
+
_(subject.tap { |s| s.type = :aeronautical_mobile_satellite_service }.guessed_unit_type).must_be_nil
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -9,49 +9,49 @@ describe AIXM::Feature::Unit do
|
|
9
9
|
macro :organisation
|
10
10
|
|
11
11
|
it "fails on nil value" do
|
12
|
-
[nil].wont_be_written_to subject, :organisation
|
12
|
+
_([nil]).wont_be_written_to subject, :organisation
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe :name= do
|
17
17
|
it "fails on invalid values" do
|
18
|
-
[nil, :foobar, 123].wont_be_written_to subject, :name
|
18
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :name
|
19
19
|
end
|
20
20
|
|
21
21
|
it "upcases and transcodes valid values" do
|
22
|
-
subject.tap { |s| s.name = 'Nîmes-Alès APP' }.name.must_equal 'NIMES-ALES APP'
|
22
|
+
_(subject.tap { |s| s.name = 'Nîmes-Alès APP' }.name).must_equal 'NIMES-ALES APP'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe :type= do
|
27
27
|
it "fails on invalid values" do
|
28
|
-
[nil, :foobar, 123].wont_be_written_to subject, :type
|
28
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :type
|
29
29
|
end
|
30
30
|
|
31
31
|
it "looks up valid values" do
|
32
|
-
subject.tap { |s| s.type = :flight_information_centre }.type.must_equal :flight_information_centre
|
33
|
-
subject.tap { |s| s.type = :MET }.type.must_equal :meteorological_office
|
32
|
+
_(subject.tap { |s| s.type = :flight_information_centre }.type).must_equal :flight_information_centre
|
33
|
+
_(subject.tap { |s| s.type = :MET }.type).must_equal :meteorological_office
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe :class= do
|
38
38
|
it "fails on invalid values" do
|
39
|
-
[nil, :foobar, 123].wont_be_written_to subject, :class
|
39
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :class
|
40
40
|
end
|
41
41
|
|
42
42
|
it "looks up valid values" do
|
43
|
-
subject.tap { |s| s.class = :icao }.class.must_equal :icao
|
44
|
-
subject.tap { |s| s.class = :OTHER }.class.must_equal :other
|
43
|
+
_(subject.tap { |s| s.class = :icao }.class).must_equal :icao
|
44
|
+
_(subject.tap { |s| s.class = :OTHER }.class).must_equal :other
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe :airport= do
|
49
49
|
it "fails on invalid values" do
|
50
|
-
[:foobar, 123].wont_be_written_to subject, :airport
|
50
|
+
_([:foobar, 123]).wont_be_written_to subject, :airport
|
51
51
|
end
|
52
52
|
|
53
53
|
it "accepts valid values" do
|
54
|
-
[nil, AIXM::Factory.airport].must_be_written_to subject, :airport
|
54
|
+
_([nil, AIXM::Factory.airport]).must_be_written_to subject, :airport
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -69,7 +69,7 @@ describe AIXM::Feature::Unit do
|
|
69
69
|
it "builds correct complete OFMX" do
|
70
70
|
2.times { subject.add_service(service) }
|
71
71
|
AIXM.ofmx!
|
72
|
-
subject.to_xml.must_equal <<~END
|
72
|
+
_(subject.to_xml).must_equal <<~END
|
73
73
|
<!-- Unit: PUJAUT TWR -->
|
74
74
|
<Uni source="LF|GEN|0.0 FACTORY|0|0">
|
75
75
|
<UniUid>
|
@@ -212,7 +212,7 @@ describe AIXM::Feature::Unit do
|
|
212
212
|
AIXM.ofmx!
|
213
213
|
subject.airport = subject.remarks = nil
|
214
214
|
subject.instance_variable_set(:'@services', [])
|
215
|
-
subject.to_xml.must_equal <<~END
|
215
|
+
_(subject.to_xml).must_equal <<~END
|
216
216
|
<!-- Unit: PUJAUT TWR -->
|
217
217
|
<Uni source="LF|GEN|0.0 FACTORY|0|0">
|
218
218
|
<UniUid>
|
@@ -226,5 +226,13 @@ describe AIXM::Feature::Unit do
|
|
226
226
|
</Uni>
|
227
227
|
END
|
228
228
|
end
|
229
|
+
|
230
|
+
it "builds OFMX with mid" do
|
231
|
+
AIXM.ofmx!
|
232
|
+
AIXM.config.mid_region = 'LF'
|
233
|
+
_(subject.to_xml).must_match /<UniUid mid="92534b75-1c12-edc5-351b-740cb82e87dd">/
|
234
|
+
_(subject.to_xml).must_match /<SerUid mid="9240cf80-9cba-7ea5-ae39-6b682305db78">/
|
235
|
+
_(subject.to_xml).must_match /<FqyUid mid="48d8e7db-88b1-8e2f-2f27-2c2521e7ac27">/
|
236
|
+
end
|
229
237
|
end
|
230
238
|
end
|
@@ -7,11 +7,11 @@ describe AIXM::Feature do
|
|
7
7
|
|
8
8
|
describe :source= do
|
9
9
|
it "fails on invalid values" do
|
10
|
-
[:foobar, 123].wont_be_written_to subject, :source
|
10
|
+
_([:foobar, 123]).wont_be_written_to subject, :source
|
11
11
|
end
|
12
12
|
|
13
13
|
it "accepts nil value" do
|
14
|
-
[nil].must_be_written_to subject, :source
|
14
|
+
_([nil]).must_be_written_to subject, :source
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,19 +19,19 @@ describe AIXM::Feature do
|
|
19
19
|
it "recognizes features with identical UID as equal" do
|
20
20
|
a = AIXM::Factory.organisation
|
21
21
|
b = AIXM::Factory.organisation
|
22
|
-
a.must_equal b
|
22
|
+
_(a).must_equal b
|
23
23
|
end
|
24
24
|
|
25
25
|
it "recognizes features with different UID as unequal" do
|
26
26
|
a = AIXM::Factory.polygon_airspace
|
27
27
|
b = AIXM::Factory.circle_airspace
|
28
|
-
a.wont_equal b
|
28
|
+
_(a).wont_equal b
|
29
29
|
end
|
30
30
|
|
31
31
|
it "recognizes objects of different class as unequal" do
|
32
32
|
a = AIXM::Factory.organisation
|
33
33
|
b = :oggy
|
34
|
-
a.wont_equal b
|
34
|
+
_(a).wont_equal b
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
data/spec/lib/aixm/p_spec.rb
CHANGED
@@ -7,136 +7,136 @@ describe AIXM::P do
|
|
7
7
|
|
8
8
|
describe :pres= do
|
9
9
|
it "fails on invalid values" do
|
10
|
-
[:foobar, -1].wont_be_written_to subject, :pres
|
10
|
+
_([:foobar, -1]).wont_be_written_to subject, :pres
|
11
11
|
end
|
12
12
|
|
13
13
|
it "converts Numeric to Float" do
|
14
|
-
subject.tap { |s| s.pres = 5 }.pres.must_equal 5.0
|
14
|
+
_(subject.tap { |s| s.pres = 5 }.pres).must_equal 5.0
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe :unit= do
|
19
19
|
it "fails on invalid values" do
|
20
|
-
[:foobar, 123].wont_be_written_to subject, :unit
|
20
|
+
_([:foobar, 123]).wont_be_written_to subject, :unit
|
21
21
|
end
|
22
22
|
|
23
23
|
it "symbolizes and downcases values" do
|
24
|
-
subject.tap { |s| s.unit = "P" }.unit.must_equal :p
|
24
|
+
_(subject.tap { |s| s.unit = "P" }.unit).must_equal :p
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe :to_p do
|
29
29
|
it "leaves pascal untouched" do
|
30
30
|
subject = AIXM.p(2, :p)
|
31
|
-
subject.to_p.must_be_same_as subject
|
31
|
+
_(subject.to_p).must_be_same_as subject
|
32
32
|
end
|
33
33
|
|
34
34
|
it "converts megapascal to pascal" do
|
35
|
-
AIXM.p(0.01, :mpa).to_p.must_equal AIXM.p(10_000, :p)
|
35
|
+
_(AIXM.p(0.01, :mpa).to_p).must_equal AIXM.p(10_000, :p)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "converts psi to pascal" do
|
39
|
-
AIXM.p(0.03, :psi).to_p.must_equal AIXM.p(206.8427187, :p)
|
39
|
+
_(AIXM.p(0.03, :psi).to_p).must_equal AIXM.p(206.8427187, :p)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "converts bar to pascal" do
|
43
|
-
AIXM.p(0.02, :bar).to_p.must_equal AIXM.p(2000, :p)
|
43
|
+
_(AIXM.p(0.02, :bar).to_p).must_equal AIXM.p(2000, :p)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "converts mmhg to pascal" do
|
47
|
-
AIXM.p(0.02, :torr).to_p.must_equal AIXM.p(2.66644, :p)
|
47
|
+
_(AIXM.p(0.02, :torr).to_p).must_equal AIXM.p(2.66644, :p)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe :to_mpa do
|
52
52
|
it "leaves megapascal untouched" do
|
53
53
|
subject = AIXM.p(2, :mpa)
|
54
|
-
subject.to_mpa.must_be_same_as subject
|
54
|
+
_(subject.to_mpa).must_be_same_as subject
|
55
55
|
end
|
56
56
|
|
57
57
|
it "converts pascal to megapascal" do
|
58
|
-
AIXM.p(10_000, :p).to_mpa.must_equal AIXM.p(0.01, :mpa)
|
58
|
+
_(AIXM.p(10_000, :p).to_mpa).must_equal AIXM.p(0.01, :mpa)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "converts psi to megapascal" do
|
62
|
-
AIXM.p(300, :psi).to_mpa.must_equal AIXM.p(2.06842719, :mpa)
|
62
|
+
_(AIXM.p(300, :psi).to_mpa).must_equal AIXM.p(2.06842719, :mpa)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "converts bar to megapascal" do
|
66
|
-
AIXM.p(22, :bar).to_mpa.must_equal AIXM.p(2.2, :mpa)
|
66
|
+
_(AIXM.p(22, :bar).to_mpa).must_equal AIXM.p(2.2, :mpa)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "converts mmhg to megapascal" do
|
70
|
-
AIXM.p(205, :torr).to_mpa.must_equal AIXM.p(0.02733101, :mpa)
|
70
|
+
_(AIXM.p(205, :torr).to_mpa).must_equal AIXM.p(0.02733101, :mpa)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe :to_psi do
|
75
75
|
it "leaves psi untouched" do
|
76
76
|
subject = AIXM.p(2, :psi)
|
77
|
-
subject.to_psi.must_be_same_as subject
|
77
|
+
_(subject.to_psi).must_be_same_as subject
|
78
78
|
end
|
79
79
|
|
80
80
|
it "converts pascal to psi" do
|
81
|
-
AIXM.p(500, :p).to_psi.must_equal AIXM.p(0.07251887, :psi)
|
81
|
+
_(AIXM.p(500, :p).to_psi).must_equal AIXM.p(0.07251887, :psi)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "converts megapascal to psi" do
|
85
|
-
AIXM.p(0.1, :mpa).to_psi.must_equal AIXM.p(14.5037738, :psi)
|
85
|
+
_(AIXM.p(0.1, :mpa).to_psi).must_equal AIXM.p(14.5037738, :psi)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "converts bar to psi" do
|
89
|
-
AIXM.p(30, :bar).to_psi.must_equal AIXM.p(435.113214, :psi)
|
89
|
+
_(AIXM.p(30, :bar).to_psi).must_equal AIXM.p(435.113214, :psi)
|
90
90
|
end
|
91
91
|
|
92
92
|
it "converts mmhg to psi" do
|
93
|
-
AIXM.p(20, :torr).to_psi.must_equal AIXM.p(0.38673443, :psi)
|
93
|
+
_(AIXM.p(20, :torr).to_psi).must_equal AIXM.p(0.38673443, :psi)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
describe :to_bar do
|
98
98
|
it "leaves bars untouched" do
|
99
99
|
subject = AIXM.p(2, :bar)
|
100
|
-
subject.to_bar.must_be_same_as subject
|
100
|
+
_(subject.to_bar).must_be_same_as subject
|
101
101
|
end
|
102
102
|
|
103
103
|
it "converts pascal to bars" do
|
104
|
-
AIXM.p(10_000, :p).to_bar.must_equal AIXM.p(0.1, :bar)
|
104
|
+
_(AIXM.p(10_000, :p).to_bar).must_equal AIXM.p(0.1, :bar)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "converts megapascal to bars" do
|
108
|
-
AIXM.p(0.1, :mpa).to_bar.must_equal AIXM.p(1, :bar)
|
108
|
+
_(AIXM.p(0.1, :mpa).to_bar).must_equal AIXM.p(1, :bar)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "converts psi to bars" do
|
112
|
-
AIXM.p(90, :psi).to_bar.must_equal AIXM.p(6.20528156, :bar)
|
112
|
+
_(AIXM.p(90, :psi).to_bar).must_equal AIXM.p(6.20528156, :bar)
|
113
113
|
end
|
114
114
|
|
115
115
|
it "converts mmhg to bars" do
|
116
|
-
AIXM.p(7000, :torr).to_bar.must_equal AIXM.p(9.33254, :bar)
|
116
|
+
_(AIXM.p(7000, :torr).to_bar).must_equal AIXM.p(9.33254, :bar)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
describe :to_torr do
|
121
121
|
it "leaves mmhg untouched" do
|
122
122
|
subject = AIXM.p(2, :torr)
|
123
|
-
subject.to_torr.must_be_same_as subject
|
123
|
+
_(subject.to_torr).must_be_same_as subject
|
124
124
|
end
|
125
125
|
|
126
126
|
it "converts pascal to mmhg" do
|
127
|
-
AIXM.p(12_000, :p).to_torr.must_equal AIXM.p(90.0072, :torr)
|
127
|
+
_(AIXM.p(12_000, :p).to_torr).must_equal AIXM.p(90.0072, :torr)
|
128
128
|
end
|
129
129
|
|
130
130
|
it "converts megapascal to mmhg" do
|
131
|
-
AIXM.p(0.1, :mpa).to_torr.must_equal AIXM.p(750.06, :torr)
|
131
|
+
_(AIXM.p(0.1, :mpa).to_torr).must_equal AIXM.p(750.06, :torr)
|
132
132
|
end
|
133
133
|
|
134
134
|
it "converts psi to mmhg" do
|
135
|
-
AIXM.p(2, :psi).to_torr.must_equal AIXM.p(103.42963306, :torr)
|
135
|
+
_(AIXM.p(2, :psi).to_torr).must_equal AIXM.p(103.42963306, :torr)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "converts bar to mmhg" do
|
139
|
-
AIXM.p(0.35, :bar).to_torr.must_equal AIXM.p(262.521, :torr)
|
139
|
+
_(AIXM.p(0.35, :bar).to_torr).must_equal AIXM.p(262.521, :torr)
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
@@ -144,46 +144,46 @@ describe AIXM::P do
|
|
144
144
|
it "recognizes objects with identical unit and pressure as equal" do
|
145
145
|
a = AIXM.p(12, :bar)
|
146
146
|
b = AIXM.p(12.0, 'BAR')
|
147
|
-
a.must_equal b
|
147
|
+
_(a).must_equal b
|
148
148
|
end
|
149
149
|
|
150
150
|
it "recognizes objects with different units and converted pressure as equal" do
|
151
151
|
a = AIXM.p(12, :bar)
|
152
152
|
b = AIXM.p(174.0452856, 'PSI')
|
153
|
-
a.must_equal b
|
153
|
+
_(a).must_equal b
|
154
154
|
end
|
155
155
|
|
156
156
|
it "recognizes objects with different units and identical pressure as unequal" do
|
157
157
|
a = AIXM.p(12, :bar)
|
158
158
|
b = AIXM.p(12, :p)
|
159
|
-
a.wont_equal b
|
159
|
+
_(a).wont_equal b
|
160
160
|
end
|
161
161
|
|
162
162
|
it "recognizes objects of different class as unequal" do
|
163
163
|
a = AIXM.p(12, :bar)
|
164
164
|
b = :oggy
|
165
|
-
a.wont_equal b
|
165
|
+
_(a).wont_equal b
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
169
|
describe :hash do
|
170
170
|
it "returns an integer" do
|
171
|
-
subject.hash.must_be_instance_of Integer
|
171
|
+
_(subject.hash).must_be_instance_of Integer
|
172
172
|
end
|
173
173
|
|
174
174
|
it "allows for the use of instances as hash keys" do
|
175
175
|
dupe = subject.dup
|
176
|
-
{ subject => true }[dupe].must_equal true
|
176
|
+
_({ subject => true }[dupe]).must_equal true
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
180
|
describe :zero? do
|
181
181
|
it "returns true for zero pressure" do
|
182
|
-
subject.tap { |s| s.pres = 0 }.must_be :zero?
|
182
|
+
_(subject.tap { |s| s.pres = 0 }).must_be :zero?
|
183
183
|
end
|
184
184
|
|
185
185
|
it "returns false for non-zero pressure" do
|
186
|
-
subject.tap { |s| s.pres = 1 }.wont_be :zero?
|
186
|
+
_(subject.tap { |s| s.pres = 1 }).wont_be :zero?
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|