Sha256: 236407dc91f40e1979d07a4cb62658b4472b6655d41cd317056de92a864d868a

Contents?: true

Size: 852 Bytes

Versions: 2

Compression:

Stored size: 852 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
      <<-JSON
        {
          "_links": {
            "self": {
              "href": "https://example.org/product/bicycle"
            },
            "parts": {
              "href": "https://example.org/product/bicycle/parts"
            }
          }
        }
      JSON
    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

2 entries across 2 versions & 1 rubygems

Version Path
excon-hypermedia-0.7.0 test/excon/links_test.rb
excon-hypermedia-0.6.0 test/excon/links_test.rb