Skip to content

Commit f17e0e1

Browse files
committed
adds note about using hal_json middleware in specs
1 parent 0d83f0a commit f17e0e1

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

UPGRADING.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@ Hyperclient.new('https://api.example.org/') do |client|
1414
end
1515
```
1616

17+
#### Changes to default headers may impact Hyperclient in test
18+
19+
If you are using Hyperclient to test an API as [described in README.md](https://github.com/codegram/hyperclient#testing-using-hyperclient) and if the API expects 'application/hal+json' as the content_type for requests, you may need to update how you set up Hyperclient in your specs. [As defined in the ```default_faraday_block``` method in ```Hyperclient::EntryPoint```](https://github.com/codegram/hyperclient/blob/9f908854395523b38e0d4fc834d6db1f8b6dfb22/lib/hyperclient/entry_point.rb#L129), you can specify that you are encoding requests via faraday as ```:hal_json```.
20+
21+
```ruby
22+
Hyperclient.new('http://example.org/api') do |client|
23+
client.connection(default: false) do |conn|
24+
conn.request :hal_json
25+
conn.response :json
26+
conn.use Faraday::Adapter::Rack, app
27+
end
28+
end
29+
```
30+
31+
instead of:
32+
33+
```ruby
34+
Hyperclient.new('http://example.org/api') do |client|
35+
client.connection(default: false) do |conn|
36+
conn.request :json
37+
conn.response :json
38+
conn.use Faraday::Adapter::Rack, app
39+
end
40+
end
41+
```
42+
1743
### Upgrading to >= 0.6.0
1844

1945
#### Changes in HTTP Error Handling
@@ -61,4 +87,3 @@ Instead Of | Write This
6187
`api.links.widget.expand(id: 3).put(name: 'updated`) | `api._links.widget._expand(id: 3)._put(name: 'updated')`
6288

6389
For more information see [#63](https://github.com/codegram/hyperclient/pull/63).
64-

0 commit comments

Comments
 (0)