Sha256: 6bf720d737c001bad5b15b515dc705d1dac642137e867267c62fd776a7926022

Contents?: true

Size: 897 Bytes

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
excon-hypermedia-0.4.3 test/excon/links_test.rb
excon-hypermedia-0.4.2 test/excon/links_test.rb
excon-hypermedia-0.4.1 test/excon/links_test.rb
excon-hypermedia-0.4.0 test/excon/links_test.rb