Sha256: cad5820e4a38b373132f2ba48ea0e153b61332d7208d4ab8eec96a2ec9c45224

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 Bytes

Contents

#encoding: utf-8

require 'test_helper'

class IpgeobaseTest < TestCase
  def setup
    @ip = '46.8.114.116'
    @stub = stub_request(:get, "#{Ipgeobase::URL}?ip=#{@ip}").
      with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
      to_return(:status => 200, :body => load_fixture('response_not_utf.xml'), :headers => {})
  end

  def test_lookup_http_query
    Ipgeobase.lookup @ip

    assert_requested @stub
  end

  def test_lookup_response_object
    meta = Ipgeobase.lookup @ip

    assert_equal 54.321480, meta.lat
  end

  def test_should_encode_to_utf8
    meta = Ipgeobase.lookup @ip

    assert_equal "Ульяновск", meta.city
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ipgeobase-0.1.2 test/lib/ipgeobase_test.rb
ipgeobase-0.1.1 test/lib/ipgeobase_test.rb