Sha256: a87fad22efe36feb3fc0365e52824d015badd27a4127a31e5ddea8cf4dc272ac
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require_relative '../test_helper' module Excon # ResourceObjectTest # # Validate the workings of `Excon::HyperResource::ResourceObject`. # class ResourceObjectTest < Minitest::Test def body <<-EOF { "_links": { "hello": { "href": "https://example.org/hello/{location}" } }, "uid": "universe", "hello": "world" } EOF end def data @data ||= JSON.parse(body) end def resource @resource ||= Excon::HyperMedia::ResourceObject.new(data) end def test_resource assert_equal data, resource.instance_variable_get(:@data) end def test_links assert_equal data['_links']['hello']['href'], resource._links.hello.href end def test_properties assert_equal 'universe', resource.uid assert_equal 'world', resource.hello assert_equal 'world', resource['hello'] assert_equal nil, resource['invalid'] end def test_correctly_raising_no_method_error assert_raises(NoMethodError) { resource.invalid } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
excon-hypermedia-0.5.3 | test/excon/resource_object_test.rb |