File: geo_spec.rb

package info (click to toggle)
ruby-twitter 7.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,856 kB
  • sloc: ruby: 10,919; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 1,225 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'helper'

describe Twitter::Geo do
  before do
    @geo = Twitter::Geo.new(coordinates: [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
  end

  describe '#==' do
    it 'returns true for empty objects' do
      geo = Twitter::Geo.new
      other = Twitter::Geo.new
      expect(geo == other).to be true
    end
    it 'returns true when objects coordinates are the same' do
      other = Twitter::Geo.new(coordinates: [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
      expect(@geo == other).to be true
    end
    it 'returns false when objects coordinates are different' do
      other = Twitter::Geo.new(coordinates: [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]])
      expect(@geo == other).to be false
    end
    it 'returns true when classes are different' do
      other = Twitter::Geo::Polygon.new(coordinates: [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
      expect(@geo == other).to be true
    end
  end
end