Sha256: 82bb319be935783d1837551f0a55baece50ca8768a75dc2ada878d59de38e530

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

require "test_helper"

class RegionsResourceTest < Minitest::Test
  def test_list
    stub = stub_request("regions", response: stub_response(fixture: "regions/list"))
    client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
    regions = client.regions.list

    assert_equal Vultr::Collection, regions.class
    assert_equal Vultr::Region, regions.data.first.class
    assert_equal 1, regions.total
  end

  def test_list_availability
    region_id = "all"
    stub = stub_request("regions/#{region_id}/availability", response: stub_response(fixture: "regions/list_availability"))
    client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
    availabilities = client.regions.list_availability(region_id: region_id)

    assert_equal Vultr::Object, availabilities.class
    assert_equal availabilities.available_plans.first, "vc2-1c-1gb"
    assert_equal availabilities.available_plans.size, 20
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vultr-2.0.0 test/vultr/resources/regions_test.rb
vultr-1.0.0 test/vultr/resources/regions_test.rb