test/test_helper.rb in excon-hypermedia-0.4.3 vs test/test_helper.rb in excon-hypermedia-0.5.0

- old
+ new

@@ -19,11 +19,12 @@ response = { headers: { 'Content-Type' => 'application/hal+json' } } Excon.stub({ method: :get, path: '/api.json' }, response.merge(body: api_body)) Excon.stub({ method: :get, path: '/product/bicycle' }, response.merge(body: bicycle_body)) Excon.stub({ method: :get, path: '/product/bicycle/wheels/front' }, response.merge(body: front_wheel_body)) Excon.stub({ method: :get, path: '/product/bicycle/wheels/rear' }, response.merge(body: rear_wheel_body)) - Excon.stub({ method: :get, path: '/product/pump' }, response.merge(body: pump_body)) + Excon.stub({ path: '/product/pump' }, response.merge(body: pump_body)) + Excon.stub({ method: :get, path: '/product/pump/parts' }, response.merge(body: parts_body)) Excon.stub({ method: :get, path: '/product/handlebar' }, response.merge(body: handlebar_body)) Excon.stub({ method: :get, path: '/api_v2.json' }, body: api_body, headers: { 'Content-Type' => 'application/json' }) end def teardown @@ -35,11 +36,11 @@ def data(name) JSON.parse(send("#{name}_body")) end def api_body - <<~EOF + <<-EOF { "_links": { "self": { "href": "https://www.example.org/api.json" }, @@ -51,11 +52,11 @@ } EOF end def bicycle_body - <<~EOF + <<-EOF { "_links": { "self": { "href": "https://www.example.org/product/bicycle" }, @@ -88,11 +89,11 @@ } EOF end def handlebar_body - <<~EOF + <<-EOF { "_links": { "self": { "href": "https://www.example.org/product/handlebar" } @@ -103,26 +104,46 @@ } EOF end def pump_body - <<~EOF + <<-EOF { "_links": { "self": { "href": "https://www.example.org/product/pump" + }, + "parts": { + "href": "https://www.example.org/product/pump/parts" } }, "weight": "2kg", "type": "Floor Pump", - "valve-type": "Presta" + "valve-type": "Presta", + "_embedded": { + "parts": #{parts_body} + } + } EOF end + def parts_body + <<-EOF + { + "_links": { + "self": { + "href": "https://www.example.org/product/pump/parts" + } + }, + "count": 47 + } + EOF + end + def rear_wheel_body - <<~EOF + <<-EOF { "_links": { "self": { "href": "https://www.example.org/product/bicycle/wheels/rear" } @@ -132,10 +153,10 @@ } EOF end def front_wheel_body - <<~EOF + <<-EOF { "_links": { "self": { "href": "https://www.example.org/product/bicycle/wheels/front" }