test/excon/hypermedia_test.rb in excon-hypermedia-0.2.0 vs test/excon/hypermedia_test.rb in excon-hypermedia-0.3.0
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+
# rubocop:disable Metrics/LineLength
require_relative '../test_helper'
module Excon
# HypermediaTest
@@ -45,10 +46,16 @@
response = client.hello(expand: { location: 'world' }).get
assert response.body.include?('http://www.example.com/hello/world/goodbye{?message}')
end
+ def test_request_using_link
+ response = client.rel('hello', expand: { location: 'world' }).get
+
+ assert response.body.include?('http://www.example.com/hello/world/goodbye{?message}')
+ end
+
def test_nested_request
hello = client.hello(expand: { location: 'world' })
response = hello.get.goodbye.get
assert_equal 'bye!', response.body
@@ -65,25 +72,25 @@
response = client.hello.get(expand: { location: 'world' })
assert response.body.include?('http://www.example.com/hello/world/goodbye{?message}')
end
- def test_attribute
+ def test_links
response = client.hello(expand: { location: 'world' }).get
- assert_equal response.uid, 'hello'
- assert_equal response.message, 'goodbye!'
+ assert_equal response.links.first.name, 'goodbye'
end
- def test_links
+ def test_link
response = client.hello(expand: { location: 'world' }).get
- assert_equal response.links.first.name, 'goodbye'
+ assert_equal response.link('goodbye').name, 'goodbye'
end
def test_attributes
response = client.hello(expand: { location: 'world' }).get
+ assert_equal response.attributes.to_h, uid: 'hello', message: 'goodbye!'
assert_equal response.attributes.uid, 'hello'
end
def teardown
Excon.stubs.clear