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,46 +7,46 @@ describe AIXM::Component::Surface do
|
|
7
7
|
|
8
8
|
describe :composition= do
|
9
9
|
it "fails on invalid values" do
|
10
|
-
[:foobar, 123].wont_be_written_to subject, :composition
|
10
|
+
_([:foobar, 123]).wont_be_written_to subject, :composition
|
11
11
|
end
|
12
12
|
|
13
13
|
it "accepts nil value" do
|
14
|
-
[nil].must_be_written_to subject, :composition
|
14
|
+
_([nil]).must_be_written_to subject, :composition
|
15
15
|
end
|
16
16
|
|
17
17
|
it "looks up valid values" do
|
18
|
-
subject.tap { |s| s.composition = :macadam }.composition.must_equal :macadam
|
19
|
-
subject.tap { |s| s.composition = :GRADE }.composition.must_equal :graded_earth
|
18
|
+
_(subject.tap { |s| s.composition = :macadam }.composition).must_equal :macadam
|
19
|
+
_(subject.tap { |s| s.composition = :GRADE }.composition).must_equal :graded_earth
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe :preparation= do
|
24
24
|
it "fails on invalid values" do
|
25
|
-
[:foobar, 123].wont_be_written_to subject, :preparation
|
25
|
+
_([:foobar, 123]).wont_be_written_to subject, :preparation
|
26
26
|
end
|
27
27
|
|
28
28
|
it "accepts nil value" do
|
29
|
-
[nil].must_be_written_to subject, :preparation
|
29
|
+
_([nil]).must_be_written_to subject, :preparation
|
30
30
|
end
|
31
31
|
|
32
32
|
it "looks up valid values" do
|
33
|
-
subject.tap { |s| s.preparation = :rolled }.preparation.must_equal :rolled
|
34
|
-
subject.tap { |s| s.preparation = 'PFC' }.preparation.must_equal :porous_friction_course
|
33
|
+
_(subject.tap { |s| s.preparation = :rolled }.preparation).must_equal :rolled
|
34
|
+
_(subject.tap { |s| s.preparation = 'PFC' }.preparation).must_equal :porous_friction_course
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe :condition= do
|
39
39
|
it "fails on invalid values" do
|
40
|
-
[:foobar, 123].wont_be_written_to subject, :condition
|
40
|
+
_([:foobar, 123]).wont_be_written_to subject, :condition
|
41
41
|
end
|
42
42
|
|
43
43
|
it "accepts nil value" do
|
44
|
-
[nil].must_be_written_to subject, :condition
|
44
|
+
_([nil]).must_be_written_to subject, :condition
|
45
45
|
end
|
46
46
|
|
47
47
|
it "looks up valid values" do
|
48
|
-
subject.tap { |s| s.condition = :fair }.condition.must_equal :fair
|
49
|
-
subject.tap { |s| s.condition = :GOOD }.condition.must_equal :good
|
48
|
+
_(subject.tap { |s| s.condition = :fair }.condition).must_equal :fair
|
49
|
+
_(subject.tap { |s| s.condition = :GOOD }.condition).must_equal :good
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -55,44 +55,44 @@ describe AIXM::Component::Surface do
|
|
55
55
|
|
56
56
|
describe :pcn= do
|
57
57
|
it "fails on invalid values" do
|
58
|
-
[25, 'X/F/B/W/U', '10/A/B', '10/A/B/C/D'].wont_be_written_to subject, :pcn
|
58
|
+
_([25, 'X/F/B/W/U', '10/A/B', '10/A/B/C/D']).wont_be_written_to subject, :pcn
|
59
59
|
end
|
60
60
|
|
61
61
|
it "accepts valid values" do
|
62
|
-
subject.tap { |s| s.pcn = nil }.pcn.must_be :nil?
|
63
|
-
subject.tap { |s| s.pcn = '25/F/B/W/U' }.pcn.must_equal '25/F/B/W/U'
|
64
|
-
subject.tap { |s| s.pcn = '10 R C X T' }.pcn.must_equal '10/R/C/X/T'
|
65
|
-
subject.tap { |s| s.pcn = "5\nF-b-y U" }.pcn.must_equal '5/F/B/Y/U'
|
62
|
+
_(subject.tap { |s| s.pcn = nil }.pcn).must_be :nil?
|
63
|
+
_(subject.tap { |s| s.pcn = '25/F/B/W/U' }.pcn).must_equal '25/F/B/W/U'
|
64
|
+
_(subject.tap { |s| s.pcn = '10 R C X T' }.pcn).must_equal '10/R/C/X/T'
|
65
|
+
_(subject.tap { |s| s.pcn = "5\nF-b-y U" }.pcn).must_equal '5/F/B/Y/U'
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe :siwl_weight= do
|
70
70
|
it "fails on invalid values" do
|
71
|
-
[:foobar, 123].wont_be_written_to subject, :siwl_weight
|
71
|
+
_([:foobar, 123]).wont_be_written_to subject, :siwl_weight
|
72
72
|
end
|
73
73
|
|
74
74
|
it "accepts valid values" do
|
75
|
-
[nil, AIXM::Factory.w].must_be_written_to subject, :siwl_weight
|
75
|
+
_([nil, AIXM::Factory.w]).must_be_written_to subject, :siwl_weight
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
describe :siwl_tire_pressure= do
|
80
80
|
it "fails on invalid values" do
|
81
|
-
[:foobar, 123].wont_be_written_to subject, :siwl_tire_pressure
|
81
|
+
_([:foobar, 123]).wont_be_written_to subject, :siwl_tire_pressure
|
82
82
|
end
|
83
83
|
|
84
84
|
it "accepts valid values" do
|
85
|
-
[nil, AIXM::Factory.p].must_be_written_to subject, :siwl_tire_pressure
|
85
|
+
_([nil, AIXM::Factory.p]).must_be_written_to subject, :siwl_tire_pressure
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
describe :auw_weight= do
|
90
90
|
it "fails on invalid values" do
|
91
|
-
[:foobar, 123].wont_be_written_to subject, :auw_weight
|
91
|
+
_([:foobar, 123]).wont_be_written_to subject, :auw_weight
|
92
92
|
end
|
93
93
|
|
94
94
|
it "accepts valid values" do
|
95
|
-
[nil, AIXM::Factory.w].must_be_written_to subject, :auw_weight
|
95
|
+
_([nil, AIXM::Factory.w]).must_be_written_to subject, :auw_weight
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -102,7 +102,7 @@ describe AIXM::Component::Surface do
|
|
102
102
|
|
103
103
|
describe :to_xml do
|
104
104
|
it "builds correct complete AIXM/OFMX" do
|
105
|
-
subject.to_xml.must_equal <<~END
|
105
|
+
_(subject.to_xml).must_equal <<~END
|
106
106
|
<codeComposition>ASPH</codeComposition>
|
107
107
|
<codePreparation>PAVED</codePreparation>
|
108
108
|
<codeCondSfc>GOOD</codeCondSfc>
|
@@ -7,12 +7,12 @@ describe AIXM::Component::Timetable do
|
|
7
7
|
|
8
8
|
describe :code= do
|
9
9
|
it "fails on invalid values" do
|
10
|
-
[nil, :foobar, 123].wont_be_written_to subject, :code
|
10
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :code
|
11
11
|
end
|
12
12
|
|
13
13
|
it "looks up valid values" do
|
14
|
-
subject.tap { |s| s.code = :notam }.code.must_equal :notam
|
15
|
-
subject.tap { |s| s.code = :H24 }.code.must_equal :continuous
|
14
|
+
_(subject.tap { |s| s.code = :notam }.code).must_equal :notam
|
15
|
+
_(subject.tap { |s| s.code = :H24 }.code).must_equal :continuous
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -22,8 +22,7 @@ describe AIXM::Component::Timetable do
|
|
22
22
|
|
23
23
|
describe :to_xml do
|
24
24
|
it "builds correct complete AIXM" do
|
25
|
-
|
26
|
-
subject.to_xml.must_equal <<~END
|
25
|
+
_(subject.to_xml).must_equal <<~END
|
27
26
|
<Timetable>
|
28
27
|
<codeWorkHr>HJ</codeWorkHr>
|
29
28
|
<txtRmkWorkHr>timetable remarks</txtRmkWorkHr>
|
@@ -32,9 +31,8 @@ describe AIXM::Component::Timetable do
|
|
32
31
|
end
|
33
32
|
|
34
33
|
it "builds correct minimal AIXM" do
|
35
|
-
AIXM.aixm!
|
36
34
|
subject.remarks = nil
|
37
|
-
subject.to_xml.must_equal <<~END
|
35
|
+
_(subject.to_xml).must_equal <<~END
|
38
36
|
<Timetable>
|
39
37
|
<codeWorkHr>HJ</codeWorkHr>
|
40
38
|
</Timetable>
|
@@ -42,8 +40,8 @@ describe AIXM::Component::Timetable do
|
|
42
40
|
end
|
43
41
|
|
44
42
|
it "builds with arbitrary tag" do
|
45
|
-
subject.to_xml.must_match(/<Timetable>/)
|
46
|
-
subject.to_xml(as: :FooBar).must_match(/<FooBar>/)
|
43
|
+
_(subject.to_xml).must_match(/<Timetable>/)
|
44
|
+
_(subject.to_xml(as: :FooBar)).must_match(/<FooBar>/)
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
@@ -7,33 +7,33 @@ describe AIXM::Component::VerticalLimits do
|
|
7
7
|
|
8
8
|
describe :upper_z= do
|
9
9
|
it "fails on invalid values" do
|
10
|
-
[nil, :foobar, 123].wont_be_written_to subject, :upper_z
|
10
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :upper_z
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe :max_z= do
|
15
15
|
it "fails on invalid values" do
|
16
|
-
[:foobar, 123].wont_be_written_to subject, :max_z
|
16
|
+
_([:foobar, 123]).wont_be_written_to subject, :max_z
|
17
17
|
end
|
18
18
|
|
19
19
|
it "accepts nil value" do
|
20
|
-
[nil].must_be_written_to subject, :max_z
|
20
|
+
_([nil]).must_be_written_to subject, :max_z
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe :lower_z= do
|
25
25
|
it "fails on invalid values" do
|
26
|
-
[nil, :foobar, 123].wont_be_written_to subject, :lower_z
|
26
|
+
_([nil, :foobar, 123]).wont_be_written_to subject, :lower_z
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe :min_z= do
|
31
31
|
it "fails on invalid values" do
|
32
|
-
[:foobar, 123].wont_be_written_to subject, :min_z
|
32
|
+
_([:foobar, 123]).wont_be_written_to subject, :min_z
|
33
33
|
end
|
34
34
|
|
35
35
|
it "accepts nil value" do
|
36
|
-
[nil].must_be_written_to subject, :max_z
|
36
|
+
_([nil]).must_be_written_to subject, :max_z
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -43,8 +43,7 @@ describe AIXM::Component::VerticalLimits do
|
|
43
43
|
upper_z: AIXM.z(2000, :qnh),
|
44
44
|
lower_z: AIXM::GROUND
|
45
45
|
)
|
46
|
-
|
47
|
-
subject.to_xml.must_equal <<~END
|
46
|
+
_(subject.to_xml).must_equal <<~END
|
48
47
|
<codeDistVerUpper>ALT</codeDistVerUpper>
|
49
48
|
<valDistVerUpper>2000</valDistVerUpper>
|
50
49
|
<uomDistVerUpper>FT</uomDistVerUpper>
|
@@ -60,8 +59,7 @@ describe AIXM::Component::VerticalLimits do
|
|
60
59
|
max_z: AIXM.z(6000, :qnh),
|
61
60
|
lower_z: AIXM.z(1000, :qfe)
|
62
61
|
)
|
63
|
-
|
64
|
-
subject.to_xml.must_equal <<~END
|
62
|
+
_(subject.to_xml).must_equal <<~END
|
65
63
|
<codeDistVerUpper>STD</codeDistVerUpper>
|
66
64
|
<valDistVerUpper>65</valDistVerUpper>
|
67
65
|
<uomDistVerUpper>FL</uomDistVerUpper>
|
@@ -80,8 +78,7 @@ describe AIXM::Component::VerticalLimits do
|
|
80
78
|
lower_z: AIXM.z(45, :qne),
|
81
79
|
min_z: AIXM.z(3000, :qnh)
|
82
80
|
)
|
83
|
-
|
84
|
-
subject.to_xml.must_equal <<~END
|
81
|
+
_(subject.to_xml).must_equal <<~END
|
85
82
|
<codeDistVerUpper>STD</codeDistVerUpper>
|
86
83
|
<valDistVerUpper>65</valDistVerUpper>
|
87
84
|
<uomDistVerUpper>FL</uomDistVerUpper>
|
@@ -4,37 +4,37 @@ describe AIXM do
|
|
4
4
|
describe :initialize_config do
|
5
5
|
it "must use AIXM" do
|
6
6
|
AIXM.send :initialize_config
|
7
|
-
AIXM.schema.must_equal :aixm
|
7
|
+
_(AIXM.schema).must_equal :aixm
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe :config do
|
12
12
|
it "must set and get arbitrary config options" do
|
13
13
|
AIXM.config.foo = :bar
|
14
|
-
AIXM.config.foo.must_equal :bar
|
14
|
+
_(AIXM.config.foo).must_equal :bar
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe :schema do
|
19
19
|
it "must return schema identifier" do
|
20
20
|
AIXM.aixm!
|
21
|
-
AIXM.schema.must_equal :aixm
|
21
|
+
_(AIXM.schema).must_equal :aixm
|
22
22
|
end
|
23
23
|
|
24
24
|
it "must return schema details" do
|
25
25
|
AIXM.aixm!
|
26
|
-
AIXM.schema(:root).must_equal 'AIXM-Snapshot'
|
26
|
+
_(AIXM.schema(:root)).must_equal 'AIXM-Snapshot'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "<schema>! and <schema>?" do
|
31
31
|
it "must set and query schemas" do
|
32
32
|
AIXM.aixm!
|
33
|
-
AIXM.must_be :aixm?
|
34
|
-
AIXM.wont_be :ofmx?
|
33
|
+
_(AIXM).must_be :aixm?
|
34
|
+
_(AIXM).wont_be :ofmx?
|
35
35
|
AIXM.ofmx!
|
36
|
-
AIXM.wont_be :aixm?
|
37
|
-
AIXM.must_be :ofmx?
|
36
|
+
_(AIXM).wont_be :aixm?
|
37
|
+
_(AIXM).must_be :ofmx?
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/spec/lib/aixm/d_spec.rb
CHANGED
@@ -7,97 +7,97 @@ describe AIXM::D do
|
|
7
7
|
|
8
8
|
describe :dist= do
|
9
9
|
it "fails on invalid values" do
|
10
|
-
[:foobar, -1].wont_be_written_to subject, :dist
|
10
|
+
_([:foobar, -1]).wont_be_written_to subject, :dist
|
11
11
|
end
|
12
12
|
|
13
13
|
it "converts Numeric to Float" do
|
14
|
-
subject.tap { |s| s.dist = 5 }.dist.must_equal 5.0
|
14
|
+
_(subject.tap { |s| s.dist = 5 }.dist).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 = "NM" }.unit.must_equal :nm
|
24
|
+
_(subject.tap { |s| s.unit = "NM" }.unit).must_equal :nm
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe :to_ft do
|
29
29
|
it "leaves feet untouched" do
|
30
30
|
subject = AIXM.d(2, :ft)
|
31
|
-
subject.to_ft.must_be_same_as subject
|
31
|
+
_(subject.to_ft).must_be_same_as subject
|
32
32
|
end
|
33
33
|
|
34
34
|
it "converts kilometers to feet" do
|
35
|
-
AIXM.d(0.5, :km).to_ft.must_equal AIXM.d(1640.4199475, :ft)
|
35
|
+
_(AIXM.d(0.5, :km).to_ft).must_equal AIXM.d(1640.4199475, :ft)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "converts meters to feet" do
|
39
|
-
AIXM.d(200, :m).to_ft.must_equal AIXM.d(656.167979, :ft)
|
39
|
+
_(AIXM.d(200, :m).to_ft).must_equal AIXM.d(656.167979, :ft)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "converts nautical miles to feet" do
|
43
|
-
AIXM.d(0.5, :nm).to_ft.must_equal AIXM.d(3038.05774277, :ft)
|
43
|
+
_(AIXM.d(0.5, :nm).to_ft).must_equal AIXM.d(3038.05774277, :ft)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe :to_km do
|
48
48
|
it "leaves kilometers untouched" do
|
49
49
|
subject = AIXM.d(2, :km)
|
50
|
-
subject.to_km.must_be_same_as subject
|
50
|
+
_(subject.to_km).must_be_same_as subject
|
51
51
|
end
|
52
52
|
|
53
53
|
it "converts feet to kilometers" do
|
54
|
-
AIXM.d(10_000, :ft).to_km.must_equal AIXM.d(3.048, :km)
|
54
|
+
_(AIXM.d(10_000, :ft).to_km).must_equal AIXM.d(3.048, :km)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "converts meters to kilometers" do
|
58
|
-
AIXM.d(2000, :m).to_km.must_equal AIXM.d(2, :km)
|
58
|
+
_(AIXM.d(2000, :m).to_km).must_equal AIXM.d(2, :km)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "converts nautical miles to kilometers" do
|
62
|
-
AIXM.d(10, :nm).to_km.must_equal AIXM.d(18.52, :km)
|
62
|
+
_(AIXM.d(10, :nm).to_km).must_equal AIXM.d(18.52, :km)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe :to_m do
|
67
67
|
it "leaves meters untouched" do
|
68
68
|
subject = AIXM.d(2, :m)
|
69
|
-
subject.to_m.must_be_same_as subject
|
69
|
+
_(subject.to_m).must_be_same_as subject
|
70
70
|
end
|
71
71
|
|
72
72
|
it "converts feet to meters" do
|
73
|
-
AIXM.d(500, :ft).to_m.must_equal AIXM.d(152.4, :m)
|
73
|
+
_(AIXM.d(500, :ft).to_m).must_equal AIXM.d(152.4, :m)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "converts kilometers to meters" do
|
77
|
-
AIXM.d(1.3, :km).to_m.must_equal AIXM.d(1300, :m)
|
77
|
+
_(AIXM.d(1.3, :km).to_m).must_equal AIXM.d(1300, :m)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "converts nautical miles to meters" do
|
81
|
-
AIXM.d(0.8, :nm).to_m.must_equal AIXM.d(1481.6, :m)
|
81
|
+
_(AIXM.d(0.8, :nm).to_m).must_equal AIXM.d(1481.6, :m)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
describe :to_nm do
|
86
86
|
it "leaves nautical miles untouched" do
|
87
87
|
subject = AIXM.d(2, :nm)
|
88
|
-
subject.to_nm.must_be_same_as subject
|
88
|
+
_(subject.to_nm).must_be_same_as subject
|
89
89
|
end
|
90
90
|
|
91
91
|
it "converts feet to nautical miles" do
|
92
|
-
AIXM.d(11_000, :ft).to_nm.must_equal AIXM.d(1.81036717, :nm)
|
92
|
+
_(AIXM.d(11_000, :ft).to_nm).must_equal AIXM.d(1.81036717, :nm)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "converts kilometers to nautical miles" do
|
96
|
-
AIXM.d(17, :km).to_nm.must_equal AIXM.d(9.17926565, :nm)
|
96
|
+
_(AIXM.d(17, :km).to_nm).must_equal AIXM.d(9.17926565, :nm)
|
97
97
|
end
|
98
98
|
|
99
99
|
it "converts meters to nautical miles" do
|
100
|
-
AIXM.d(5800, :m).to_nm.must_equal AIXM.d(3.13174946, :nm)
|
100
|
+
_(AIXM.d(5800, :m).to_nm).must_equal AIXM.d(3.13174946, :nm)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -105,46 +105,46 @@ describe AIXM::D do
|
|
105
105
|
it "recognizes objects with identical unit and distance as equal" do
|
106
106
|
a = AIXM.d(123, :m)
|
107
107
|
b = AIXM.d(123.0, 'M')
|
108
|
-
a.must_equal b
|
108
|
+
_(a).must_equal b
|
109
109
|
end
|
110
110
|
|
111
111
|
it "recognizes objects with different units and converted distance as equal" do
|
112
112
|
a = AIXM.d(123, :m)
|
113
113
|
b = AIXM.d(403.54330709, 'FT')
|
114
|
-
a.must_equal b
|
114
|
+
_(a).must_equal b
|
115
115
|
end
|
116
116
|
|
117
117
|
it "recognizes objects with different units and identical distance as unequal" do
|
118
118
|
a = AIXM.d(123, :m)
|
119
119
|
b = AIXM.d(123, :ft)
|
120
|
-
a.wont_equal b
|
120
|
+
_(a).wont_equal b
|
121
121
|
end
|
122
122
|
|
123
123
|
it "recognizes objects of different class as unequal" do
|
124
124
|
a = AIXM.d(123, :m)
|
125
125
|
b = :oggy
|
126
|
-
a.wont_equal b
|
126
|
+
_(a).wont_equal b
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
describe :hash do
|
131
131
|
it "returns an integer" do
|
132
|
-
subject.hash.must_be_instance_of Integer
|
132
|
+
_(subject.hash).must_be_instance_of Integer
|
133
133
|
end
|
134
134
|
|
135
135
|
it "allows for the use of instances as hash keys" do
|
136
136
|
dupe = subject.dup
|
137
|
-
{ subject => true }[dupe].must_equal true
|
137
|
+
_({ subject => true }[dupe]).must_equal true
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
141
|
describe :zero? do
|
142
142
|
it "returns true for zero distance" do
|
143
|
-
subject.tap { |s| s.dist = 0 }.must_be :zero?
|
143
|
+
_(subject.tap { |s| s.dist = 0 }).must_be :zero?
|
144
144
|
end
|
145
145
|
|
146
146
|
it "returns false for non-zero distance" do
|
147
|
-
subject.tap { |s| s.dist = 1 }.wont_be :zero?
|
147
|
+
_(subject.tap { |s| s.dist = 1 }).wont_be :zero?
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|