test/excon/hcp_test.rb in excon-hypermedia-0.5.2 vs test/excon/hcp_test.rb in excon-hypermedia-0.5.3

- old
+ new

@@ -7,11 +7,11 @@ # # Validate the workings of `Excon::HyperResource::Middlewares::HypertextCachePattern`. # class HCPTest < HyperMediaTest def response - @response ||= Excon.get('https://example.org/product/bicycle') + bicycle end def test_non_hcp_response assert_equal nil, response[:hcp] end @@ -19,20 +19,25 @@ def test_hcp_response assert response.rel('pump', hcp: true).get[:hcp] end def test_hcp_response_without_existing_response - assert Excon.get('https://example.org/product/bicycle', hcp: true) + assert Excon.get(url('/product/bicycle'), hcp: true) end def test_hcp_response_with_missing_embedding - api = Excon.get('https://www.example.org/api.json') response = api.rel('product', expand: { uid: 'bicycle' }, hcp: true).get assert_equal nil, response[:hcp] end + def test_hcp_response_with_embedding_but_missing_embed_for_request + handlebar = response.rel('handlebar', hcp: true).get + + assert_equal nil, handlebar[:hcp] + end + def test_hcp_response_with_embedded_array wheels = response.rel('wheels', hcp: true) assert wheels.map(&:get).all? { |res| res[:hcp] } end @@ -40,13 +45,9 @@ def test_nested_hcp_responses pump = response.rel('pump', hcp: true).get response = pump.rel('parts', expand: { uid: 'bicycle' }).get assert response[:hcp] - end - - def test_hcp_not_working_for_non_get_requests - assert_equal nil, response.rel('pump', hcp: true).post[:hcp] end def test_hcp_resource resource = response.rel('pump', hcp: true).get.resource