spec/unit/datacite/mapping/geo_location_spec.rb in datacite-mapping-0.2.5 vs spec/unit/datacite/mapping/geo_location_spec.rb in datacite-mapping-0.3.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'spec_helper'
module Datacite
module Mapping
@@ -43,15 +45,15 @@
loc = GeoLocation.new(place: place)
expect(loc.place).to eq(place)
end
it 'accepts a polygon' do
polygon = GeoLocationPolygon.new(points: [
- GeoLocationPoint.new(47.61, -122.33),
- GeoLocationPoint.new(-33.45, -122.33),
- GeoLocationPoint.new(47.61, -70.67),
- GeoLocationPoint.new(47.61, -122.33)
- ])
+ GeoLocationPoint.new(47.61, -122.33),
+ GeoLocationPoint.new(-33.45, -122.33),
+ GeoLocationPoint.new(47.61, -70.67),
+ GeoLocationPoint.new(47.61, -122.33)
+ ])
loc = GeoLocation.new(polygon: polygon)
expect(loc.polygon).to eq(polygon)
end
it 'allows an empty location' do
loc = GeoLocation.new
@@ -104,15 +106,15 @@
end
describe '#polygon=' do
it 'sets the polygon' do
polygon = GeoLocationPolygon.new(points: [
- GeoLocationPoint.new(47.61, -122.33),
- GeoLocationPoint.new(-33.45, -122.33),
- GeoLocationPoint.new(47.61, -70.67),
- GeoLocationPoint.new(47.61, -122.33)
- ])
+ GeoLocationPoint.new(47.61, -122.33),
+ GeoLocationPoint.new(-33.45, -122.33),
+ GeoLocationPoint.new(47.61, -70.67),
+ GeoLocationPoint.new(47.61, -122.33)
+ ])
loc = GeoLocation.new
loc.polygon = polygon
expect(loc.polygon).to eq(polygon)
end
end
@@ -166,15 +168,15 @@
expect(loc.point).to eq(GeoLocationPoint.new(31.233, -67.302))
expect(loc.box).to eq(GeoLocationBox.new(41.09, -71.032, 42.893, -68.211))
expect(loc.place).to eq('Atlantic Ocean')
actual_polygon = loc.polygon
expected_polygon = GeoLocationPolygon.new(points: [
- GeoLocationPoint.new(31.233, -67.302),
- GeoLocationPoint.new(-68.211, -71.032),
- GeoLocationPoint.new(42.893, 41.09),
- GeoLocationPoint.new(31.233, -67.302)
- ])
+ GeoLocationPoint.new(31.233, -67.302),
+ GeoLocationPoint.new(-68.211, -71.032),
+ GeoLocationPoint.new(42.893, 41.09),
+ GeoLocationPoint.new(31.233, -67.302)
+ ])
expect(actual_polygon).to eq(expected_polygon)
end
it 'trims place-name whitespace' do
xml_text = '<geoLocation>
@@ -194,16 +196,16 @@
before(:each) do
@loc = GeoLocation.new(
point: GeoLocationPoint.new(31.233, -67.302),
box: GeoLocationBox.new(41.09, -71.032, 42.893, -68.211),
place: 'Atlantic Ocean',
- polygon: (GeoLocationPolygon.new(points: [
- GeoLocationPoint.new(-67.302, 31.233),
- GeoLocationPoint.new(-71.032, -68.211),
- GeoLocationPoint.new(41.09, 42.893),
- GeoLocationPoint.new(-67.302, 31.233)
- ]))
+ polygon: GeoLocationPolygon.new(points: [
+ GeoLocationPoint.new(-67.302, 31.233),
+ GeoLocationPoint.new(-71.032, -68.211),
+ GeoLocationPoint.new(41.09, 42.893),
+ GeoLocationPoint.new(-67.302, 31.233)
+ ])
)
end
describe 'DC4 mode' do
it 'writes DC4' do
@@ -255,10 +257,10 @@
expect_warning(loc.polygon.to_s, 1)
end
it 'writes DC3 in XSD-defined order: point, box, place' do
actual_xml = loc.save_to_xml(mapping: :datacite_3)
- expected_order = %w(geoLocationPoint geoLocationBox geoLocationPlace)
+ expected_order = %w[geoLocationPoint geoLocationBox geoLocationPlace]
actual_order = actual_xml.children.map(&:name)
expect(actual_order).to eq(expected_order)
end
end
end