Sha256: 5b31cb24e09b597c68903e0d4a20496bae40229c774a1dbb500855cb41576afd

Contents?: true

Size: 897 Bytes

Versions: 3

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true
# rubocop:disable Metrics/MethodLength

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://www.example.org/product/bicycle"
            },
            "parts": {
              "href": "https://www.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

3 entries across 3 versions & 1 rubygems

Version Path
excon-hypermedia-0.5.2 test/excon/links_test.rb
excon-hypermedia-0.5.1 test/excon/links_test.rb
excon-hypermedia-0.5.0 test/excon/links_test.rb