Sha256: afc5a89eb43f60bf41e806911405e39f02eab6b430cc08a36cd96a3e0db56fee

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

module Datacite
  module Mapping
    describe GeoLocationPolygon do
      describe '#==' do
        it 'reports equal values as equal' do
          polygon1 = GeoLocationPolygon.new(points: [
            GeoLocationPoint.new(-33.45, -122.33),
            GeoLocationPoint.new(33.45, -122.33),
            GeoLocationPoint.new(33.45, 122.33),
            GeoLocationPoint.new(-33.45, -122.33)
          ])
          polygon2 = GeoLocationPolygon.new(points: [
            GeoLocationPoint.new(-33.45, -122.33),
            GeoLocationPoint.new(33.45, -122.33),
            GeoLocationPoint.new(33.45, 122.33),
            GeoLocationPoint.new(-33.45, -122.33)
          ])
          expect(polygon1).to eq(polygon2)
          expect(polygon1.hash).to eq(polygon2.hash)
          expect(polygon2).to eq(polygon1)
          expect(polygon2.hash).to eq(polygon1.hash)
        end

        it 'reports unequal values as unequal' do
          polygon1 = GeoLocationPolygon.new(points: [
            GeoLocationPoint.new(-33.45, -122.33),
            GeoLocationPoint.new(33.45, -122.33),
            GeoLocationPoint.new(33.45, 122.33),
            GeoLocationPoint.new(-33.45, -122.33)
          ])
          polygon2 = GeoLocationPolygon.new(points: [
            GeoLocationPoint.new(33.45, 122.33),
            GeoLocationPoint.new(-33.45, 122.33),
            GeoLocationPoint.new(-33.45, -122.33),
            GeoLocationPoint.new(33.45, 122.33)
          ])
          expect(polygon1).not_to eq(polygon2)
          expect(polygon1.hash).not_to eq(polygon2.hash)
          expect(polygon2).not_to eq(polygon1)
          expect(polygon2.hash).not_to eq(polygon1.hash)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datacite-mapping-0.2.5 spec/unit/datacite/mapping/geo_location_polygon_spec.rb
datacite-mapping-0.2.4 spec/unit/datacite/mapping/geo_location_polygon_spec.rb
datacite-mapping-0.2.3 spec/unit/datacite/mapping/geo_location_polygon_spec.rb
datacite-mapping-0.2.2 spec/unit/datacite/mapping/geo_location_polygon_spec.rb
datacite-mapping-0.2.1 spec/unit/datacite/mapping/geo_location_polygon_spec.rb
datacite-mapping-0.2.0 spec/unit/datacite/mapping/geo_location_polygon_spec.rb