Skip to content
Snippets Groups Projects
Commit c8e0b908 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge pull request #274 from petergoldstein/feature/get_jruby_tests_green

Get tests running green under JRuby
parents 9adbf399 ec7a0c94
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,11 @@ gemspec
group :development, :test do
gem 'rake'
gem 'mongoid'
gem 'bson_ext'
gem 'bson_ext', :platforms => :ruby
gem 'rails'
end
\ No newline at end of file
platforms :jruby do
gem 'jruby-openssl'
end
end
require 'net/http'
require 'net/https'
require 'uri'
unless defined?(ActiveSupport::JSON)
......
......@@ -152,24 +152,24 @@ class CalculationsTest < Test::Unit::TestCase
def test_extract_coordinates
result = Geocoder::Calculations.extract_coordinates([ nil, nil ])
assert_equal [ Geocoder::Calculations::NAN ] * 2, result
assert is_nan_coordinates?(result)
result = Geocoder::Calculations.extract_coordinates([ 1.0 / 3, 2.0 / 3 ])
assert_in_delta 1.0 / 3, result.first, 1E-5
assert_in_delta 2.0 / 3, result.last, 1E-5
result = Geocoder::Calculations.extract_coordinates(nil)
assert_equal [ Geocoder::Calculations::NAN ] * 2, result
assert is_nan_coordinates?(result)
result = Geocoder::Calculations.extract_coordinates('')
assert_equal [ Geocoder::Calculations::NAN ] * 2, result
assert is_nan_coordinates?(result)
result = Geocoder::Calculations.extract_coordinates([ 'nix' ])
assert_equal [ Geocoder::Calculations::NAN ] * 2, result
assert is_nan_coordinates?(result)
o = Object.new
result = Geocoder::Calculations.extract_coordinates(o)
assert_equal [ Geocoder::Calculations::NAN ] * 2, result
assert is_nan_coordinates?(result)
def o.to_coordinates
[ 1.0 / 3, 2.0 / 3 ]
......
......@@ -271,5 +271,11 @@ class Test::Unit::TestCase
def street_lookups
all_lookups - [:freegeoip]
end
def is_nan_coordinates?(coordinates)
return false unless coordinates.respond_to? :size # Should be an array
return false unless coordinates.size == 2 # Should have dimension 2
coordinates[0].nan? && coordinates[1].nan? # Both coordinates should be NaN
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment