Sha256: 168db22317d5e33588cfa353bad368d1750d171a4df4934e93d2cdef81ce6d36

Contents?: true

Size: 1.94 KB

Versions: 19

Compression:

Stored size: 1.94 KB

Contents

require File.expand_path('../../test_helper', __FILE__)

module Checkr
  class GeoTest < Test::Unit::TestCase
    setup do
      @geo_url = "#{Checkr.api_base}/v1/geos"
    end

    context 'Geo class' do
      should 'be retrieveable' do
        id = "geo_id"
        @mock.expects(:get).once.with("#{@geo_url}/#{id}", anything, anything).returns(test_response(test_geo))
        geo = Geo.retrieve(id)
        assert(geo.is_a?(Geo))
      end

      should 'be createable' do
        @mock.expects(:post).once.with(@geo_url, anything, test_geo).returns(test_response(test_geo))
        geo = Geo.create(test_geo)
        assert(geo.is_a?(Geo))
        assert_equal(test_geo[:id], geo.id)
      end
    end

    context 'Geo instance' do
      should 'be refreshable' do
        @mock.expects(:get).once.with("#{@geo_url}/#{test_geo[:id]}", anything, anything).returns(test_response(test_geo))
        geo = Geo.new(test_geo[:id])
        geo.refresh
        assert_equal(test_geo[:name], geo.name)
      end
    end


    context 'Retrieved Geo instance' do
      setup do
        @mock.expects(:get).once.returns(test_response(test_geo))
        @geo = Geo.retrieve('geo_id')
      end

      should 'have the id attribute' do
        assert_equal(test_geo[:id], @geo.id)
      end

      should 'have the object attribute' do
        assert_equal(test_geo[:object], @geo.object)
      end

      should 'have the uri attribute' do
        assert_equal(test_geo[:uri], @geo.uri)
      end

      should 'have the created_at attribute' do
        assert_equal(test_geo[:created_at], @geo.created_at)
      end

      should 'have the name attribute' do
        assert_equal(test_geo[:name], @geo.name)
      end

      should 'have the state attribute' do
        assert_equal(test_geo[:state], @geo.state)
      end

    end

    should 'be registered' do
      assert(APIClass.subclasses.include?(Geo))
      assert_equal(Geo, APIClass.subclass_fetch("geo"))
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
checkr-official-1.8.0 test/checkr/geo_test.rb
checkr-official-1.7.1 test/checkr/geo_test.rb
checkr-official-1.7 test/checkr/geo_test.rb
checkr-official-1.6 test/checkr/geo_test.rb
checkr-official-1.5.4 test/checkr/geo_test.rb
checkr-official-1.5.3 test/checkr/geo_test.rb
checkr-official-1.5.2 test/checkr/geo_test.rb
checkr-official-1.5.1 test/checkr/geo_test.rb
checkr-official-1.5.0 test/checkr/geo_test.rb
checkr-official-1.4.0 test/checkr/geo_test.rb
checkr-official-1.3.1 test/checkr/geo_test.rb
checkr-official-1.2.1 test/checkr/geo_test.rb
checkr-official-1.2.0 test/checkr/geo_test.rb
checkr-official-1.1.2 test/checkr/geo_test.rb
checkr-official-1.1.1 test/checkr/geo_test.rb
checkr-official-1.1.0 test/checkr/geo_test.rb
checkr-official-1.0.2 test/checkr/geo_test.rb
checkr-official-1.0.1 test/checkr/geo_test.rb
checkr-official-1.0.0 test/checkr/geo_test.rb