Sha256: e35fa55bc13c4937caf60df8386bc79d42612e6febfebaae761ca870cf20cdd6

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true

require_relative '../test_helper'

module Excon
  # LinksTest
  #
  # Validate the workings of `Excon::HyperResource::Resource::Links`.
  #
  class LinksTest < Minitest::Test
    def body
      <<-EOF
        {
          "_links": {
            "self": {
              "href": "https://example.org/product/bicycle"
            },
            "parts": {
              "href": "https://example.org/product/bicycle/parts"
            }
          }
        }
      EOF
    end

    def data
      JSON.parse(body)
    end

    def links
      @links ||= Excon::HyperMedia::ResourceObject::Links.new(data['_links'])
    end

    def test_links
      assert_equal Excon::HyperMedia::ResourceObject::Links, links.class
    end

    def test_link_properties
      assert_equal %w(self parts), links.to_h.keys
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
excon-hypermedia-0.5.3 test/excon/links_test.rb